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
Rishabh Dugar: 2013-10-26 13:27:29

use double instead of float

pm: 2013-08-24 20:41:44

easy :)

rathor ashu: 2013-08-09 09:10:59

use double to print
float cause me a one wrong answer

ওয়াসী (Wasi): 2013-05-04 14:37:17

AC...
Python 3.2.3 run time 0.10 :D

Last edit: 2013-08-21 15:02:57

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