spoj#REBOUND. The return of the Cake
The return of the Cake
It is well known that, in byteland, when you throw a cake, the angle of reflexion is not the angle of incidence. Measured from the ground, the angle is the double, in byteland!
You stand at point A(0, z), and you want to throw a cake in Leo's face. Leo stands at B(x, y) and is a very dangerous man, so you decide to use the ground in order to make your cake rebound.
Your shot is precise only if you can use an integer value t in the intervall [0, x], in order to reflect on C(t, 0). Sometimes it's possible, sometimes not!
Input
The input begins with the number T of test cases in a single line. In each of the next T lines there are three integers x, y and z, explaining the locations : you A(0, z), Leo B(x, y).
Output
For each test case, find and print the only integer t such 0 <= t <= x, that allow this perfect shot. If it's not possible, output "Not this time.".
Example
Input: 3 5 4 1 6 5 2 7 3 1</p>Output: 2 Not this time. 3
Comment : the last case is the one illustrated above.
Constraints
1 < T < 100 000 0 < x < 1 000 000 000 0 < y < 1 000 000 000 0 < z < 1 000 000 000
Edit(2017-02-11) : New time limit (after compiler changes).