#P5970. [POI 2016] Nim z utrudnieniem
[POI 2016] Nim z utrudnieniem
Problem Description
Two players, A and B, play a game. There are stones in total. A splits them into piles, where the numbers of stones in each pile are . In each round, a player may choose one pile and remove any positive number of stones from it, but they cannot remove zero stones. The first player who cannot make a move loses.
Before the game starts, B may discard some piles of stones, but B must ensure that the number of discarded piles is a multiple of , and B cannot discard all stones.
A moves first. Ask how many ways B can discard piles such that B can win.
Input Format
The first line contains two positive integers .
The second line contains positive integers .
Output Format
Output one line with one integer, the number of valid ways modulo .
5 2
1 3 4 1 2
2
Hint
For of the testdata, , , . is not given directly, but the testdata guarantees that .
Translated by ChatGPT 5