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
sk128: 2021-04-01 15:11:48

I used the correct logic ,took time because I forgot to separate answers with an endl :(

rounik: 2020-09-25 06:40:29

AC in one go

pandey101299: 2019-02-10 12:25:34

So easy problem Ac in one go....

Last edit: 2019-02-10 12:26:04
sanchit_aga: 2019-01-08 17:55:46

Keep an eye on how you print your decimals, for example 0.66666667 will give AC while 0.66666666 will give WA if probability is 2/3. This cost me a WA.

sanjay5797: 2017-06-23 15:40:35

my 150th!!!...AC in one go....
should be moved to tutorials!!

iharsh234: 2015-12-31 18:42:18

not classical one!
move to tutorials

adi_tri: 2015-08-13 21:31:58

should be move to where....yes...in tutorials...

cosmopoliton: 2015-03-20 06:38:31

dam easy once you get the right relation

Lehar: 2015-02-21 11:32:11

AC after a month! :D

Indian Cyber Army (IndiShell): 2015-02-05 14:28:32

AC in 1st go .. :)
[Spoiler Removed]

re(vamsi): please don't comment on every other problem you solve unless it is important(related to problem/IO formatting) or the problem is too good

Last edit: 2015-02-05 16:24:21

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