P22307 [HackerRank] Random number generator 1
提高-
题目描述

Sabya is writing code to output a random number between $1$ and $N$ inclusive. The code can output different integers in the interval with different probabilities so that the sum of the probabilities is equal to $1$.

For evaluation, the code is run twice. If the output in both cases are different, his score is equal to the sum of the outputs. Otherwise, his score is equal to $0$.

Sabya is very intelligent, and he writes code that maximizes his expected score. Find the expected score. Output the ratio of the expected score to the maximum possible score. The maximum possible score is $2\times N-1$.

Input Format

The first line contains $\mathbf{T}$: the number of test cases.

The next $\mathbf{T}$ lines each contain a single integer, $N$.

Output Format

Output $\mathbf{T}$ lines: the ratio $\frac{\text{expected score}}{\text{maximum score}}$ in each case.

The answer is considered correct if the absolute error is less than $\mathbf{10^{-8}}$.

Constraints

$1\leq T\leq10^5$

$1\leq N\leq10^6$

Sample Input
3
1
2
3

Sample Output
0.00000000000
0.50000000000
0.54545454545

Explanation

In the first case, the output is always $1$ both times.

In the second case, $1$ and $2$ are generated with the probability of $\frac{1}{2}$ and $\frac{1}{2}$

In the third case, $1$, $2$ and $3$ are generated with the probability of $\frac{5}{22}$, $\frac{4}{11}$ and $\frac{9}{22}$, respectively.

输入格式

见题面

输出格式

见题面

样例输入
3 1 2 3
样例输出
0.00000000000 0.50000000000 0.54545454545