Light Bulb Game
Time limit1sMemory limit128 MB
Count the ways to pick m distinct switch-combinations over n bulbs (unordered as a set of turns) whose XOR sum turns on exactly the first v bulbs, modulo 10567201.
- Level
Hard8 of 10
- Topics
- Combinatorics, Math, Bit manipulation
- Solved
- No attempts yet
Problem
Sanggeun has bulbs and switches. Each bulb is either on or off, and each switch is connected to one bulb. Pressing a switch flips the state of its bulb: pressing the switch of a bulb that is on turns it off, and pressing the switch of a bulb that is off turns it on. Initially every bulb is off. Sanggeun invented a game with these bulbs.
One turn consists of choosing a combination of switches and pressing exactly those switches. Choosing no switch at all is also a valid combination. After turns, the first bulbs must be on and all the others off. The game has one restriction: the same combination may not be used more than once.
Because the game is very easy, there are a great many ways to win, and Sanggeun wants to find them all. Write a program that computes how many winning ways there are in total.
Given two winning ways and , if can be turned into by suitably reordering its turns, they count as the same way.
For example, when , , , you can win by pressing 1, 2, 4 on the first turn, 1, 3 on the second turn, and 1, 3, 4 on the third turn. This way is the same as pressing 1, 3 on the first turn, 1, 2, 4 on the second turn, and 1, 3, 4 on the third turn.
Input
The input consists of several test cases, at most 500 of them. Each test case is a single line containing (), (), and (). The last line contains 0 0 0.
Output
For each test case, print the number of ways to win the game modulo .