#P1588. [USACO07OPEN] Catch That Cow S
[USACO07OPEN] Catch That Cow S
Description
FJ lost one of his cows and decided to get it back. FJ and the cow are on a number line with initial positions and , and the cow stays put. In each move, if FJ is at position , he can move to , , or . Compute the minimum number of moves needed for FJ to catch the cow.
Input Format
The first line contains an integer ( ), the number of test cases.
Each of the next lines contains two positive integers ( ), representing the coordinates of FJ and the cow, respectively.
Output Format
For each test case, output the minimum number of moves.
1
5 17
4
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号