Given a non-negative number n and two values l and r. The problem is to count the number of unset bits in the range l to r in the binary representation of n, i.e. to count unset bits from the rightmost lth bit to the rightmost rth bit.
Input : n = 42, l = 2, r = 5 Output : 2 (42)10 = (101010)2 There are '2' unset bits in the range 2 to 5. Input : n = 80, l = 1, r = 4 Output : 4
Input: The first line of the input contains a single integer T, denoting the number of test cases. ThenT test cases follow. Each test-case has one line of the input, the line contains three integers n, l and r.
Output: Print the required output.
64 4 7
80 1 4
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.