A horseshoe is located in the central house of a table that is infinite on all sides.…
- User
A horseshoe is located in the central house of a table that is infinite on all sides. This bead has chosen a house as its destination and wants to reach that house in the fastest possible way. You have to find the least possible number of moves.
More precisely, at first the horse in the house ( 0 , 0 ) (0,0) the table is located. You must have the minimum number of moves required for the horse to go home ( x , y ) Find (x,y).
In each movement, the horse piece can move two houses forward in one of the vertical or horizontal directions and move forward one house in the other direction. These eight houses are marked in red in the figure below.
Allowed movements of a horse
input In the first line of the input, a natural number t t is given. 1 ≤ t ≤ 3000 1≤t≤3000
in line i iam from t t next line, two numbers x i x i and y i y i has come 0 ≤ x i , y i ≤ 1 0 9 0 ≤ x i ,y i ≤10 9
output Your answer should include t t is a line. on the line i iam must be the minimum movement required by the horse to reach ( x i , y i ) (x i ,y i ) starting from ( 0 , 0 ) Print (0,0).
examples Sample entry 1 6 1 1 2 1 2 2 3 3 3 1 2000 0 Plain text Sample output 1 2 1 4 2 2 1000 Plain text Description of the image
The path of the horse to the house ( 1 , 1 ) (1,1) can be found in the figure below according to the pink numbers. The path of the horse to the house ( 2 , 1 ) (2,1) can be found in the figure below according to the brown number. The path of the horse to the house ( 2 , 2 ) (2,2) can be found in the figure below according to the black numbers. The path of the horse to the house ( 3 , 3 ) (3,3) can be found in the figure below according to the purple numbers. The path of the horse to the house ( 3 , 1 ) (3,1) can be found in the figure below according to the pink and blue numbers. write in c++
- Assistant