Rightmost different bit
Submissions: 4576   Accuracy:

71.38%

  Difficulty: Basic   Marks: 1
Associated Course(s):   Sudo Placement [IITs]
     

Given two numbers M and N. Write a program to find the position of rightmost different bit in binary representation of numbers.

Input:
The input line contains T, denoting the number of testcases. Each testcase follows. First line of each testcase contains two space separated integers M and N.

Output:
For each testcase in new line, print the position of rightmost different bit in binary representation of numbers. If both M and N are same then print -1 in this case.

Constraints:
1 <= T <= 100
1 <= M <= 1000
1 <= N <= 1000

Example:
Input:
2
11 9
52 4

Output:
2
5

Explanation:
Tescase 1:
Binary representaion of the given numbers are: 1011 and 1001, 2nd bit from right is different.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harsh Agarwal
Author: harsh.agarwal0


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.