![]() |
||||||||||
|
||||||||||
Gaming of Co-prime DisallowanceTime Limit: 3000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 296 Accepted Submission(s): 98 Special Judge Problem Description It is preferrable to read the pdf statment. Cuber QQ and Little Fang are playing a game, called Gaming of Co-prime Disallowance (GCD). To play GCD, two tables are needed. The game starts with $n$ cards on one table, and players take turns to move the cards to another table. In each turn, a player has to select one and only one card and move it. Let's assume that the players have moved $k$ cards, and there are $n-k$ cards left. The players who cannot make a move any more loses the game. If one of the following two conditions happen, the players can no longer make a move:
To test the fairness of GCD, Cuber QQ and Little Fang plays completely randomly without any strategy at all. Help him calculate how likely he is going to win if Cuber QQ plays first. Input The first line of the input contains a single integer $T$ ($1\le T\le 150$), denoting the number of test cases. Each of the next $T$ cases:
It is guaranteed that $\sum n \le 8~000$. Output For each test case, output one line contains a real number --- the probability that Cuber QQ will win the game. Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$. Hint For the first sample: Cuber QQ will win if the players take turns to select the number in this way : $2,1$ ; $2,3$ ; $3,1$ ; $3,2$; $3,4$ ;$4,1$ ; $4,3$ So the probability that Cuber QQ will win the game is $\frac{1}{4}\cdot \frac{1}{3}\times 4+\frac{1}{4}=\frac{7}{12}$ Sample Input
Sample Output
Source | ||||||||||
|