SolveMe
Time limit8sMemory limit512 MB
Count pairs of maps A and B on N rooms where following A X times, then B, A Y times, B, and A Z times returns every room to its start, modulo 1,000,000,007.
- Level
Hard9 of 10
- Topics
- Combinatorics, Math, Number theory
- Solved
- No attempts yet
Problem
There are rooms, and each room's floor has a picture of a rabbit. If you stand on the right ear of the rabbit picture in room , you teleport onto the tail of the rabbit drawn in room . Likewise, standing on the left ear of the rabbit picture in room teleports you onto the tail of the rabbit drawn in room .
You are given integers , , and . The cat wants to set the teleports so that the following condition holds. Among the ways to set the teleports, count how many satisfy the condition, modulo 1,000,000,007.
Condition: For every room , starting from , if you step on the right ear exactly times, the left ear exactly once, the right ear exactly times, the left ear exactly once, and the right ear exactly times, you return to .
Input
The input is given in the following format:
Output
Print the number of teleport settings that satisfy the condition, modulo 1,000,000,007, on a single line.
Constraints
- is between 1 and 1,000, inclusive.
- , , and are between 0 and 1,000,000,000,000,000,000, inclusive.