This problem was used in the following GFU competitions:
GFU 2024 D2 Q3
GFU 2024 D1 Q1
You are given two integers, A and B. You want to transform A to B by performing a sequence of operations. You can only perform the following operations:
• Divide A by two, but only if A is even.
• Add one to A.
What is the minimum number of operations you need to transform A into B?
The input will begin with a single integer n, the number of test cases to follow. For each test case, there will be the two integers A(1 <= A <= 109) and B(1 <= B <= 109) .
For each test case, output a single line containing the minimum number of operations to transform A to B.
Example Input:
2
103 27
3 8
Example Output:
4
5
This is a pretty simple program... no real tips/tricks.