Round 1
Questions: Suppose there is a grid consisting of an infinite number of cells and you are standing on cell (0,0).
Let your move strength be K which is initially set to 1.
In one move you can perform the following operations:
- Move horizontally i.e. (x+k,y) from (x,y)
- Move vertically i.e. (x,y+k) from (x,y)
- Increase the value of K by 1
Find and print the minimum number of moves to reach the destination cell represented by (a,b).
Input Each test contains multiple test cases. The first line contains the number of test cases t(1≤t≤10^3). Description of the test cases follows.
The first line and only line of each test case contain two-spaced integers a and b(1≤a,b≤10^9).
Output Print the minimum moves for each test case in separate lines.
Example Input
2 1 6 1 1
Output
5 2
For the first test case, First move to (1,0), then increase the value of K to 2, and then move three times to reach (1,6). Hence, it takes a total of 5.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.