5972: ABC212 —— H - Nim Counting
Description
Given are positive integers NN, KK, and a sequence of KK integers (A1,A2,…,AK)(A1,A2,…,AK).
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 pla
The pla
Now, consider the initial arrangements of stones satisfying the following.
Assuming that the heaps are ordered, there are K+K2+⋯+KNK+K2+⋯+KN such initial arrangements of stones. Among them, find the number, modulo 998244353998244353, of arrangements that lead to Takahashi's win, assuming that both pla
Input
$N\ K$
$A_1\ A_2\ \dots\ A_K$
Output
Constraints
$1≤K<2{16}$
$1≤A_i<2^{16}$
All $A_i$ are distinct.
All values in input are integers.
Sample 1 Input
2 2
1 2
Sample 1 Output
4
Takahashi has a winning strategy for four of them: $(1),\ (2),\ (1,\ 1),\ (1,\ 2),\ (2,\ 1),\ (2,\ 2)$, and Aoki has a winning strategy for the other two. Thus, we should print $4$.
Sample 2 Input
100 3
3 5 7
Sample 2 Output
112184936