Problem · Math
Reach The Point
Learn this problemProblem statement
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:
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.
Function
minimumMoves(a: int, b: int) → intExamples
Example 1
a = 1b = 6return = 5For 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.
Example 2
a = 1b = 1return = 2:)
Constraints
1 ≤ t ≤ 10^31 ≤ a, b ≤ 10^9