IEEEBGAM - The Ball Game

no tags 

Taru and Hanaku play a ball game. The game is played with N white balls, N black balls and N boxes. Hanaku chooses one box randomly and one ball from it randomly. Taru has to arrange the balls in such a way that the probability of Hanaku choosing a White ball is maximised. None of the boxes after the arrangement should be empty. Your task is to find that maximum probability.

Input

The first line contains the number of test cases (T) followed by T lines each an integer N.

Output

For each test case output the maximum probability of getting a white ball which is possible with an arrangement for the above configuration. Print the answer rounded to 8 decimal places.

Constraints

T <= 20
N <= 1000

Example

Sample Input:
1
1

Sample Output:
0.50000000

hide comments
! include(L.ppt): 2012-04-03 16:32:06

nice puzzle problem asked once to me in an interview.....:)

Alex Anderson: 2012-03-28 21:10:24

It is relatively clear that all the balls need to be put in the boxes.

Devil D: 2012-03-28 05:02:32

@ymGXX - there is 1 white ball and 1 black ball in the Only box :) So probability is 1/2 = 0.50
..
problem setter should also mention that the black balls also need to be put in the boxes

ymGXX: 2012-03-27 14:49:51

How does sample input get 0.5?
I can put a white ball in the only box so the answer should be 1?


Added by:Saransh Bansal
Date:2012-03-21
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64