Submit solution


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

Author:
Problem type

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

Alice and Bob will spend the rest of eternity competing in this \pi 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

1 \le T \le 314\,159
X + Y \ge 1

Subtask 1 [27%]

0 \le X,Y \le 314
1 \le Z \le 2

Subtask 𝓮 [31%]

0 \le X,Y \le 314
1 \le Z \le 271

Subtask π [42%]

0 \le X,Y \le 314\,159
1 \le Z \le 271\,828

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 \pi e, Y is the initial number of bad slices of \pi e, and Z is the number of randomly good/bad \pi e slices which are added after each turn. It is guarenteed that there is at least one slice of \pi e initially.

Output Specificiation

Output T lines, the i^{th} line containing one real number, the answer to the i^{th} testcase. Your answers will be considered correct if their absolute error is less than 10^{-6}.

Sample Input

3
1 0 2
2 4 3
5 2 4

Sample Output

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 \frac{\pi}{4} = 0.7853981633974483\dots

For the second testcase, it can be shown that the limit of the expected value approaches \frac{2}{3}\ln(2) - \frac{2}{3} = -0.20456854629336979\dots

For the third testcase, it can be shown that the limit of the expected value approaches \frac{3\sqrt{2}}{4}\ln(1+\sqrt{2}) - \frac{3\sqrt{2}}{8}\pi + 1 = 0.2687567584009584\dots


Comments

There are no comments at the moment.