xor game
Time limit0.5sMemory limit128 MB
Count sequences of n xor masks (each below 2^31) that carry a to b, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Math, Combinatorics, Bit manipulation, Dynamic programming
- Solved
- No attempts yet
Problem
chogahui05 plays an xor game. The game runs for turns, and there is an unlimited supply of cards for every integer from to . The rules are the following.
- chogahui05 starts holding the card with the integer on it.
- On every turn chogahui05 must do the following.
- Pick one integer with .
- Let be the number on the card currently held. Replace that card with the card that has on it. Here is the bitwise exclusive or.
When the game ended, the number on the card chogahui05 held was .
Find the number of possible game processes modulo (). Two processes are different when the integer picked on some turn is different.
Input
The first line contains the integers , () and (), separated by spaces.
Output
Print on the first line the number of possible game processes modulo .
Hint
Take , , . There is only one turn, so the only possibility is picking and replacing the card with the one that has on it.