Puzzle at Braavos

5

3 votes
Medium
Problem

Daenerys Targaryen wants to fund her war efforts but she is short of money. Given her financial needs, she was advised by her advisers to visit Braavos and seek funding from the Iron Bank. When she reached Braavos, she came across a member of Faceless Men. The member invited her for a betting game and said that if she wins in this, he will give double the amount she has betted.

The game is a two player turn-based game(i.e. each player gets his turn one by one) and consists of four piles. Each pile has some number of discs. Each player, in his turn, can take any number of discs from at most two piles and has to take at least one disc from any pile. The Faceless Men further refused to tell her the number of discs in each piles but agreed to tell her sum total of discs in all piles and also agreed her to be the first player in the game. He also agreed to play T number of games with her. Being tight on finances, she would like to play only few of the T games.

Danerys assumed that given N, the total number of discs, any configuration of four distinguishable piles is equally likely. She also assumes that both she and the Faceless men will play optimally for each configuration. She wants to calculate her probability of winning given her assumption is correct(i.e. fraction of games she will win if all possible configurations of four distinguishable piles for a given N are equally likely and both players play optimally). Can you help her to calculate this probability?

Input

The first line contains T, the number of games.

Each test case contains only one integer N denoting the total number of discs.

Output

The output should contain 1 real number per test case denoting the probability of winning of Daenerys given that she is first player in the game described above.

Constraints

1 <= T <= 10^6

1 <= N <= 10^5

Note

Output value should be within 1e-6 of the correct value(Output should be printed to exactly six places of decimal precision).

Partial Marks are awarded if some of the test cases pass ( Beware that passing the first test case will not give you any marks).

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

There are four configurations possible for four distinct piles as shown:

Configuration 1: 1 0 0 0

Configuration 2: 0 1 0 0

Configuration 3: 0 0 1 0

Configuration 4: 0 0 0 1

As Daenerys is the first player, she wins in all the above four possible games. Thus her probability of winning is 1.000000

Editor Image

?