Nội dung Bài tập
Mã:
Phuc1
Tên:
Up and Down
Dạng thi:
oi
Thang điểm:
10 điểm
Giới hạn thời gian:
1 giây
Giới hạn bộ nhớ:
256 MB
Nguồn bài tập:
SCPC 2019
Được tạo bởi:
phucnq

Given an integer greater than or equal to 1 , you are going to play a game where you repeat the “operation”, of which the rules are given below.
The rule below is for one operation.
You will run the operation on the resulting integer repeatedly.
As you can see in the rules, when the integer you have equals 1 , no operation is performed and the game stops.

 1. If the current integer is 1 , no operation is performed and the game stops
 2. If the current integer is an odd number other than 1 , you add 1 to it.
 3. If the current integer is even, you divide it by 2 .

For example, if you are initially given 2, 21 and the game stops after 1 operation.
If you are initially given 4 , 421 and the game stops after 2 operations.
If you are initially given 3 , 3421 and the game stops after 3 operations.
If you are initially given 6 , 63421 and the game stops after 4 operations.
As you can see in the previous two examples, if you know the number of operations for 3 , then you will immediately know the number of operations for 6 .

You are to write a program that calculates the total number of operations for N1,N1+1,N1+2,,N2, given N1 and N2 (1N1N2106).


- Time Limit: 1 second for at most 10,000 test cases. (if you program in Java, then you have 2 seconds).


If your program exceeds the time limit, then it is terminated immediately.  
You can still obtain partial scores (0≤ your score< full score) in that case. If you program in C/C++, use “setbuf(stdout, NULL);” just once before your first call of printf.
If you don’t do this and your program exceeds the time limit, your score is 0 and you cannot obtain partial scores.  
If you program in C++, use "setbuf(stdout, NULL);" as above and use “cout” instead of "printf" to obtain partial scores. 
If you program in Java, use "System.out.printIn".
※ Check the provided sample code for details. 
If you get partial score when your program runs within the time limit, it failed in some test cases.  

- Memory Limit : heap, global, static 256MB, stack 100MB
- Allowed number of submissions: 10 (if two or more have the same score, the one with the fewer number of submissions gets higher rank.)

Memory Limit

heap, global, static (in total) : 256MB
stack : 100MB

Input

There can be more than one test case in the input file. 
The first line has T, the number of test cases.  
Then  T cases are provided in the following lines. (1T10,000)
The first line of each test case consists of two integers N1 and N2. (1N1N2106)


- Scores : The maximum scores out of your submissions. (Full score: 100)
   The group of test cases are as follows. When you report the right answers for all test cases in a group, you get its partial score. 
 
ㆍ Group 1 (34 points) : 1N1N2103.
ㆍ Group 2 (66 points) : No additional restrictions beyond the input specification. 

Output

For each test case, you are supposed to write its answer to the standard output in the same order as the input.
For the C-th test case, “Case #C” should be printed out in the first line. 
The following line should contain the total sum of number of operations for