#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 nn piles of stones on the ground (each pile has fewer than 10410^4 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 nn 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 TT (T10T \le 10), indicating there are TT sets of testdata.

Next, each set of testdata consists of two lines. The first line contains an integer nn, the number of piles, with n104n \le 10^4.

The second line contains nn integers, representing the number of stones in each pile.

Output Format

Output TT 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