atcoder#ABC212H. [ABC212H] Nim Counting
[ABC212H] Nim Counting
Score : points
Problem Statement
Given are positive integers , , and a sequence of integers .
Takahashi and Aoki will play a game with stones. Initially, there are some heaps of stones, each of which contains one or more stones. The players take turns doing the following operation, with Takahashi going first.
- Choose a heap with one or more stones remaining. Remove any number of stones between and (inclusive) from that heap, where is the number of stones remaining.
The player who first gets unable to do the operation loses.
Now, consider the initial arrangements of stones satisfying the following.
- holds, where is the number of heaps of stones.
- The number of stones in each heap is one of the following: .
Assuming that the heaps are ordered, there are such initial arrangements of stones. Among them, find the number, modulo , of arrangements that lead to Takahashi's win, assuming that both players play optimally.
Constraints
- All are distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 2
1 2
4
There are six possible initial arrangements of stones: , , , , , and . Takahashi has a winning strategy for four of them: , , , and , and Aoki has a winning strategy for the other two. Thus, we should print .
100 3
3 5 7
112184936
Be sure to find the count modulo .