The Team Work
Practice
0 (0 votes)
Easy
Problem
35% Success 67 Attempts 20 Points 0.5s Time Limit 256MB Memory 1024 KB Max Code

Ankit was recently solving problems on an online judge, he came across a question that seemed easy but Ankit was not able to solve it. He was very sad regarding this. Ankit and Sintu were teammates for an upcoming programming competition and were practicing together. Ankit took the task to Sintu and now they worked out like a team and Bamm! they found the solution.

The problem is as follows, given test cases, each test case will have two integers n and m. You can perform two types of operations :-

  1. Subtract 1 from n 
  2. Multiply with 2

Now the task is simple you have to find the minimum number of operations required to convert to and for each test case print the answer on a new line.

Constraints :- 

1 <= t <= 105

1 <= n,m <= 104

Sample Input :-

2

4 6

10 1

Sample Output :-

2

9

Problem Author :- Sintu Kumar , Ankit Raj

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
17 votes
Tags:
MathematicsOpenApprovedEasyMathamatics
Points:20
2 votes
Tags:
ImplementationEasySimple-math
Points:20
11 votes
Tags:
OpenApprovedEasyMathamatics