#P2197. 【模板】Nim 游戏
【模板】Nim 游戏
Description
Two players, A and B, are playing the Nim game.
The rules of the Nim game are as follows: There are piles of stones on the ground (each pile has fewer than stones). On each turn, a player may remove any positive number of stones from exactly one pile; it is allowed to take all stones from that pile, but taking none is not allowed. The player who cannot make a move (i.e., when no stones remain) loses. Given that A moves first and the sizes of the piles are known, determine whether there exists a winning strategy for the first player.
Input Format
This problem has multiple testdata.
The first line contains an integer (), indicating there are sets of testdata.
Next, each set of testdata consists of two lines. The first line contains an integer , the number of piles, with .
The second line contains integers, representing the number of stones in each pile.
Output Format
Output lines. For each set of testdata, output Yes if there exists a winning strategy for the first player; otherwise, output No.
2
2
1 1
2
1 0
No
Yes
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号