#P7609. [THUPC 2021] 游戏

[THUPC 2021] 游戏

Description

Xiao C and Xiao W plan to play a two-player combinatorial game.

Xiao C has nn identical stones. Xiao W will split them into mm ordered piles. For the ii-th pile, the number of stones cannot exceed aia_i, but it is allowed to be 00.

Then Xiao C moves first, and they take turns making moves. Each move, a player may choose a non-empty pile and take away some stones from it (at least 11). The player who cannot make a move loses.

As experienced competitive programmers, Xiao C and Xiao W already know the strategies for many games very well, so this time they want to do something different: they want to know how many ways of splitting the stones make Xiao C have a winning strategy.

Input Format

The first line contains two positive integers n,mn, m (1n10181 \le n \le {10}^{18}, 1m101 \le m \le 10).

The second line contains mm non-negative integers aia_i (0ai10180 \le a_i \le {10}^{18}).

Output Format

Output one non-negative integer, the number of valid ways modulo 998244353998244353.

6 3
2 3 4

4

Hint

Sample Explanation

The following 44 ways satisfy the requirement: (0,2,4)(0,2,4), (1,1,4)(1,1,4), (2,0,4)(2,0,4), (2,2,2)(2,2,2).

Source

From the 2021 Tsinghua University Student Programming Contest and Intercollegiate Invitational (THUPC2021).

Resources such as the editorial can be found at https://github.com/yylidiw/thupc_2/tree/master.

Translated by ChatGPT 5