Problems > Bounded XOR Count

Bounded XOR Count

Difficulty: 2200 5000 ms 128 MB

bitwise digit-dp

Count the integers i in [0, N] such that i XOR X is at most Y.

Input: one line with three integers N, X, Y.

Output: the count of qualifying i.

Constraints:

  • 0 ≤ N, X, Y ≤ 1012

Sample Tests

Input 1
5 3 4
Output 1
4
Input 2
0 0 0
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.