100 atcoder#ABC128C. [ABC128C] Switches
[ABC128C] Switches
Score : points
Problem Statement
We have switches with "on" and "off" state, and bulbs. The switches are numbered to , and the bulbs are numbered to .
Bulb is connected to switches: Switch , , , and . It is lighted when the number of switches that are "on" among these switches is congruent to modulo .
How many combinations of "on" and "off" states of the switches light all the bulbs?
Constraints
- is or .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of combinations of "on" and "off" states of the switches that light all the bulbs.
2 2
2 1 2
1 2
0 1
1
- Bulb is lighted when there is an even number of switches that are "on" among the following: Switch and .
- Bulb is lighted when there is an odd number of switches that are "on" among the following: Switch .
There are four possible combinations of states of (Switch , Switch ): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print .
2 3
2 1 2
1 1
1 2
0 0 1
0
- Bulb is lighted when there is an even number of switches that are "on" among the following: Switch and .
- Bulb is lighted when there is an even number of switches that are "on" among the following: Switch .
- Bulb is lighted when there is an odd number of switches that are "on" among the following: Switch .
Switch has to be "off" to light Bulb and Switch has to be "on" to light Bulb , but then Bulb will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print .
5 2
3 1 2 5
2 2 3
1 0
8