#P5589. 小猪佩奇玩游戏
小猪佩奇玩游戏
Description
Peppa and George are playing a game.
Peppa writes the numbers on the blackboard. Each round, they will choose a number that is currently on the blackboard uniformly at random, and then delete all positive integer powers of .
Formally, given the sequence , each time they uniformly select number that exists in the sequence, and delete all numbers of the form .
They played for a whole afternoon, but the game still did not end, so they want to know: after how many rounds is the game expected to end.
If the absolute error between your answer and the correct answer is within , then it will be judged as correct.
Input Format
The first line contains positive integer , meaning Peppa and George plan to play games.
Then follow lines, each with positive integer , meaning Peppa wrote the numbers on the blackboard and will start the game.
Output Format
Output a total of lines, each containing decimal number, representing the answer. Keep the decimals.
If the absolute error between your answer and the correct answer is within , then it will be judged as correct.
5
4
8
16
32
100
3.50000000
7.00000000
13.83333333
28.33333333
93.41666667
Hint
For ,
If the deletion order is , then the probability is $\frac{1}{4} \times \frac{1}{3} \times \frac{1}{1}=\frac{1}{12}$.
If the deletion order is , then the probability is $\frac{1}{4} \times \frac{1}{3} \times \frac{1}{2}=\frac{1}{24}$.
If the deletion order is , then the probability is $\frac{1}{4} \times \frac{1}{2} \times \frac{1}{1}=\frac{1}{8}$.
For the remaining sequences that delete times, the probability is $\frac{1}{4} \times \frac{1}{3} \times \frac{1}{2} \times \frac{1}{1}=\frac{1}{24}$.
It is easy to see that the answer is $\frac{2 \times 3}{12} + \frac{2 \times 3}{24}+\frac{2 \times 3}{8} + \frac{12 \times 4}{24}=\frac{7}{2}=3.50000$.
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
A Friendly Reminder from the Problem Setter
For C++ users, for positive integers , if you want to compute , please try not to use the built-in C++ function , in order to avoid possible unnecessary precision errors.
Input Format
The first line contains positive integer , meaning Peppa and George plan to play games.
Then follow lines, each with positive integer , meaning Peppa wrote the numbers on the blackboard and will start the game.
Output Format
Output a total of lines, each containing decimal number, representing the answer. Keep the decimals.
If the absolute error between your answer and the correct answer is within , then it will be judged as correct.
Hint
For ,
If the deletion order is , then the probability is $\frac{1}{4} \times \frac{1}{3} \times \frac{1}{1}=\frac{1}{12}$.
If the deletion order is , then the probability is $\frac{1}{4} \times \frac{1}{3} \times \frac{1}{2}=\frac{1}{24}$.
If the deletion order is , then the probability is $\frac{1}{4} \times \frac{1}{2} \times \frac{1}{1}=\frac{1}{8}$.
For the remaining sequences that delete times, the probability is $\frac{1}{4} \times \frac{1}{3} \times \frac{1}{2} \times \frac{1}{1}=\frac{1}{24}$.
It is easy to see that the answer is $\frac{2 \times 3}{12} + \frac{2 \times 3}{24}+\frac{2 \times 3}{8} + \frac{12 \times 4}{24}=\frac{7}{2}=3.50000$
Translated by ChatGPT 5
京公网安备 11011102002149号