Primes and XOR? Nonsense
Time limit2sMemory limit1024 MB
Given L and R up to 1e12, count the integers that can be formed as the XOR of some subset of the primes in [L, R].
- Level
Hard8 of 10
- Topics
- Number theory, Bit manipulation, Math
- Solved
- No attempts yet
Problem
Define , where is the set of prime numbers. In other words, is the set of all primes between and inclusive.
Given and , find the number of integers that can be represented as the XOR of some subset (possibly empty) of .
Input
The first line contains one integer (), the number of independent test cases. Each of the next lines contains two integers and ().
Output
For each test case, print the answer on a separate line.
Hint
In the first example, .
In the second example, , so only can be represented as the XOR of some subset.