Akku and Binary Numbers
Easy Accuracy: 9.61% Submissions: 1267 Points: 2

Akku likes binary numbers and she likes playing with these numbers. Her teacher once gave her a question.For given value of  L and R, Akku have to find the count of number X, which have only three-set bits in it's binary representation such that "L <= X <= R".Akku is genius, she solved the problem easily. Can you do it ??


The first line of input contains of an integer T i.e number of test cases. Next T lines contains  two space seperated integers L,R


Output consists of T lines each indicating the answer for each test case.


1 <= T <= 10000
1 <= L <= R <= 10^18


Sample Input :

11 19

Sample Output :


Explanation :

There are 4 such numbers with 3 set bits in range 11 to 19.

11 -> 1011

13 -> 1101

14 -> 1110

19 -> 10011

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.