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
freaker: 2014-12-20 07:37:07

1 line code in perl ...

Aditya Joshi: 2014-10-03 10:03:34

Be careful with the formatting of your answer. In Java use the DecimalFormat class to format your answer to 8 decimal places and remember to append a "0" to the start since DecimalFormat will return strings of the form .324 etc.

Raghav Aggiwal: 2014-09-06 19:08:58

think like a kid ... easiest problem ever

unagi: 2014-07-09 15:08:56

@rishabh your comment helped, using float gives wa

Diksha Jaiswal: 2014-06-27 06:08:06

easy....11 lines of code :)

sarelfeniel: 2014-06-18 11:00:00

Nice and easy, although the wording is a bit strange and could be made clearer.

pvkcse: 2014-06-08 23:31:16

for me it's four lines with python3.2.3...!!!

zai zai: 2014-03-27 01:06:43

one line in python :)

Piyush Raman Srivastava: 2014-01-23 20:24:26

tried this quest 1st time on 10-30-2012!!
now got AC!! what a logic!! unnecessarily complicated by me! :p

Anubhav Balodhi : 2013-12-30 12:41:42

Probability rocks ^_^
rounding off, and ans on...


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