Problem J: Table Tennis
题号:NC224033
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
Special Judge, 64bit IO Format: %lld

题目描述

Alex is attending the first edition of Robotic World Championship of Table Tennis. A competition that have all of the matches having the same rules listed below:
•A match shall consist of the best of 7 games, i.e., the results of matches must be 4 games to k, where 0 ≤ k ≤3.
•A game shall be won by the player first scoring 11 points unless both players score 10 points, when the game shall be won by the first player subsequently gaining a lead of 2 points. For example, a game can be won at scores like 11-5, 11-9 or 12-10, but not 10-5 or 11-10.
•After each 2 points have been scored the receiving player shall become the serving player and so on until the end of the game, unless both players score 10 points, when the sequences of serving and receiving shall be the same but each player shall serve for only 1 point in turn. That is, the servicing order of the first 20 points is AABBAABBAABBAABBAABB,and will be followed by ABABAB. . .if necessary.
•The player serving first in a game shall receive first in the next game of the match.
Experience tells that when two robots clashes into each other, the variances affecting their winning chances can be simplified to who’s serving for the point. This is due to the performances of the robots are physically consistent and won’t be affected mentally.
Alex have listed some of the possible matchups, simplified to the winning chance of each servicing point of the robots, for you. Now it is your job to help him calculate the winning chance of each match for them.

输入描述:

The first line of the input consists of a single number T, indicating that there will be T test cases following.
Each of the following test case consists of two space-separated real numbers PA and PB in one line, where PA denotes the Robot A’s chance of winning the point when A is serving and PB denotes the Robot B’s chance of winning the point when B is serving.
The Robot A always serves first in the very first game of the match.

输出描述:

For each test case, output one real number in one line: the winning chance of A.
示例1

输入

复制
3
1 0
0.5 0.5
0.00 1.00

输出

复制
1
0.5
0.000000000

备注:

•T≤100
•0≤PA≤1and has at most 2 digits after the decimal point in the input.
•0≤PB≤1and has at most 2 digits after the decimal point in the input.
•0< PA+PB<2
•The answer will be considered correct if it is within an absolute error of 10−8 of the correct answer.