Monk and his Friend
Practice
3.6 (156 votes)
Ad Hoc
Approved
Bit manipulation
Easy
Open
Problem
90% Success 17093 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Monk has a very good friend, Puchi. As weird as his name, are the games he plays.
One fine day, they decided to play a game to test how diverse their choices are. Both of them choose exactly one integer each. Monk chooses an integer M and Puchi chooses an integer P.
The diversity of their choices is defined as the number of bits whose status is different in the binary representation of M and P , i.e. , count of bits that are ,either set in M and unset in P or set in P and unset in M.
Find the answer to their game.

Input:
First line contains T. T test cases follow.
Each test case consists of 2 space-separated integers P and M.

Output:
Print the answer to each test case in a new line.

Constraints:
1 ≤ T ≤ 104
0 ≤ M, P ≤ 1016

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
71 votes
Tags:
Basic ProgrammingBit ManipulationBit manipulationMath
Points:30
17 votes
Tags:
Easy
Points:20
14 votes
Tags:
Bit manipulationBit ManipulationBasics of Bit ManipulationBasic Programming