atcoder#ABC138F. [ABC138F] Coincidence
[ABC138F] Coincidence
Score : points
Problem Statement
Given are integers and . Find the number, modulo , of pairs of integers such that the remainder when is divided by is equal to .
What is $\text{ XOR }$?
The XOR of integers and , , is defined as follows:
- When is written in base two, the digit in the 's place () is if either or , but not both, has in the 's place, and otherwise.
For example, . (In base two: .)
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the number of pairs of integers satisfying the condition, modulo .
2 3
3
Three pairs satisfy the condition: , , and .
10 100
604
1 1000000000000000000
68038601
Be sure to compute the number modulo .