#codeforcesP2009C. The Legend of Freya the Frog
The Legend of Freya the Frog
Problem
Freya the Frog is traveling on the 2D coordinate plane. She is currently at point and wants to go to point . In one move, she chooses an integer such that and jumps spots forward in the direction she is facing.
Initially, she is facing the positive direction. After every move, she will alternate between facing the positive direction and the positive direction (i.e., she will face the positive direction on her second move, the positive direction on her third move, and so on).
What is the minimum amount of moves she must perform to land on point
Input
The first line contains an integer — the number of test cases.
Each test case contains three integers and
Output
For each test case, output the number of jumps Freya needs to make on a new line.
Example : in
3
9 11 3
0 10 8
1000000 100000 10
Example : out
8
4
199999
Note
In the first sample, one optimal set of moves is if Freya jumps in the following way: $(0,0 ) →(2,0) →(2,2) →(3,2) →(3,5) →(6,5) →(6,8) →(9,8) →(9,11)$. This takes jumps.
相关
在下列比赛中: