Submit solution


Points: 15 (partial)
Time limit: 3.14s
Memory limit: 271M

Author:
Problem type

Alice and Bob have joined a competitive πe game! Initially, there are X slices of good πe, and Y slices of bad πe. With Alice going first, they will take turns picking one of the slices of πe uniformly at random and eating it. If a player eats a good slice of πe, they gain one point, and if they eat a bad slice of πe, they lose one point. After each turn, they will bake a good/bad slice of πe to replace the type of πe that was just eaten. Then, they will bake Z additional slices of πe, each with equal probability of being either good or bad.

Alice and Bob will spend the rest of eternity competing in this πe game! Determine the limit of the expected value of Alice's points minus Bob's points after n turns, as n approaches infinity. To ensure the integrity of your solution, there will be T testcases.

Constraints

1T314159
X+Y1

Subtask 1 [27%]

0X,Y314
1Z2

Subtask 𝓮 [31%]

0X,Y314
1Z271

Subtask π [42%]

0X,Y314159
1Z271828

Input Specification

The first line contains one integer, T, the number of testcases.

The next T lines each contain three space-separated integers, X, Y, and Z, describing each testcase. X is the initial number of good slices of πe, Y is the initial number of bad slices of πe, and Z is the number of randomly good/bad πe slices which are added after each turn. It is guarenteed that there is at least one slice of πe initially.

Output Specificiation

Output T lines, the ith line containing one real number, the answer to the ith testcase. Your answers will be considered correct if their absolute error is less than 106.

Sample Input

Copy
3
1 0 2
2 4 3
5 2 4

Sample Output

Copy
0.7853981633974483
-0.20456854629336979
0.2687567584009584

Explanation for Sample

For the first testcase, it can be shown that the limit of the expected value approaches π4=0.7853981633974483

For the second testcase, it can be shown that the limit of the expected value approaches 23ln(2)23=0.20456854629336979

For the third testcase, it can be shown that the limit of the expected value approaches 324ln(1+2)328π+1=0.2687567584009584


Comments

There are no comments at the moment.