Numbers with K Set Bits
Count the integers in [L, R] whose binary representation has exactly K one-bits.
Input: one line with three integers L, R, K.
Output: the count of integers with popcount K.
Constraints:
- 1 ≤ L ≤ R ≤ 1018
- 0 ≤ K ≤ 60
Sample Tests
Input 1
1 10 2
Output 1
5
Input 2
5 5 2
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.