IEEEBGAM - The Ball Game

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

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

hide comments
2014-12-20 07:37:07 freaker
1 line code in perl ...
2014-10-03 10:03:34 Aditya Joshi
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.
2014-09-06 19:08:58 Raghav Aggiwal
think like a kid ... easiest problem ever
2014-07-09 15:08:56 unagi
@rishabh your comment helped, using float gives wa
2014-06-27 06:08:06 Diksha Jaiswal
easy....11 lines of code :)
2014-06-18 11:00:00 sarelfeniel
Nice and easy, although the wording is a bit strange and could be made clearer.
2014-06-08 23:31:16 pvkcse
for me it's four lines with python3.2.3...!!!
2014-03-27 01:06:43 zai zai
one line in python :)
2014-01-23 20:24:26 Piyush Raman Srivastava
tried this quest 1st time on 10-30-2012!!
now got AC!! what a logic!! unnecessarily complicated by me! :p
2013-12-30 12:41:42 Anubhav Balodhi
Probability rocks ^_^
rounding off, and ans on...
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.