#P2197. Nim Game Winning Strategy
Nim Game Winning Strategy
Nim Game Winning Strategy
Two players, A and B, play a game of Nim. There are \( n \) piles of stones, with the number of stones in each pile being less than \(10^4\). In each turn, a player chooses exactly one pile and removes at least one stone from it; they may remove all stones from that pile. The player who is unable to move (because there are no stones left) loses the game.
Given that A takes the first turn and the sizes of the \( n \) piles are provided, determine whether A has a winning strategy. As per the theory of Nim, if the nim-sum \( S = a_1 \oplus a_2 \oplus \dots \oplus a_n \) is nonzero, then the first player can force a win.
Output "Yes" if A can force a win, and "No" otherwise.
inputFormat
The first line contains a single integer \( n \) (the number of piles). The second line contains \( n \) integers \( a_1, a_2, \dots, a_n \), where \( a_i \) represents the number of stones in the \( i \)-th pile.
outputFormat
Output a single line containing "Yes" if the first player (A) has a winning strategy, or "No" otherwise.
sample
1
5
Yes
</p>