#P17215. [ICPC 2017 Nanning R] The Champion

    ID: 16778 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 7 Uploaded By: Tags>数学2017递归概率论ICPC

[ICPC 2017 Nanning R] The Champion

题目描述

Bob is attending a chess competition. Now the competition is in the knockout phase. There are 2r2^r players now, and they will play over rr rounds.

In each knockout round, the remaining players would be divided into pairs, and the winner of each pair would advance to the next knockout round. Finally only one player would remain and be declared the champion.

Bob has already assigned all players in an order while he assigned himself to the kk-th site. A better player is located at a site with a smaller number indicating a higher order. The probability that a player with higher order wins a player with lower order is p(0≤p≤1)p (0 \le p \le 1).

Bob notices that arrangement of matches is crucial for the final result.

For example, if there are 44 players and Bob is the second best player (he is the second site), and p=0.9p = 0.9. In the first round, if Bob meets the best player, he will have only 0.1×0.9=0.090.1 \times 0.9 = 0.09 probability to become the champion. However if he does not meet the best player in the first round, he will have $0.9 \times (0.9 \times 0.1 + 0.1 \times 0.9) = 0.162$ probability to become the champion. Now Bob wants to know, what is the winning probability for him in the best arrangement of matches.

输入格式

The first line in the input contains an integer t(1≤t≤63000)t (1 \le t \le 63000) which is the number of test cases.

For each case, there is only one line containing two integers rr and kk (1≤r<64,1≤k≤2r)(1 \le r < 64,1 \le k \le 2^r) and a float-point number p(0≤p≤1)p (0 \le p \le 1) as described above.

输出格式

For each case, calculate the winning probability for Bob in the best arrangement. Output the probability with the precision of 66 digits.

2
1 1 0.8
2 2 0.9
0.800000
0.162000