Problem Statement-
“I am not in danger, Skyler. I am the danger. A guy opens his door and gets shot, and you think that of me? No! I am the one who knocks!”
Skyler fears Walter and ponders escaping to Colorado. Walter wants to clean his lab as soon as possible and then go back home to his wife.
In order clean his lab, he has to achieve cleaning level of lab as . The current cleaning level of the lab is .
He must choose one positive odd integer and one positive even integer . Note that, he cannot change or once he starts cleaning.
He can perform any one of the following operations for one round of cleaning:
- Replace with .
- Replace with .
Find minimum number of rounds (possibly zero) to make lab clean.
Input:
- First line will contain , number of test cases. testcases follow :
- Each test case contains two space separated integers .
Output:
For each test case, output an integer denoting minimum number of rounds to clean the lab.
Constraints
Sample Input:
3
0 5
4 -5
0 10000001
Sample Output:
1
2
1
EXPLANATION:
For the first testcase, you can convert to by choosing and .
It will cost minimum of cleaning round. You can select any other combination of satisfying above condition but will take minimum of cleaning round in any case.For the second testcase, you can convert to by choosing and . In first round they will replace to and then in second round replace to . You can perform only one operation in one round.
Solution-
- When , it will take operation if the difference is , else .
- When , it will take operation when difference is , when difference is but not divisible by else .
- When , it will take operation.
Comments
Post a Comment