eolymp
bolt
Try our new interface for solving problems
Problems

Playing With Stones

Playing With Stones

You and your friend are playing a game in which you and your friend take turns removing stones from piles. Initially there are \textbf{N} piles with \textbf{a_1}, \textbf{a_2}, \textbf{a_3}, ..., \textbf{a_N} number of stones. On each turn, a player must remove at least one stone from one pile but no more than half of the number of stones in that pile. The player who cannot make any moves is considered lost. For example, if there are three piles with \textbf{5}, \textbf{1} and \textbf{2} stones, then the player can take \textbf{1} or \textbf{2} stones from first pile, no stone from second pile, and only \textbf{1} stone from third pile. Note that the player cannot take any stones from the second pile as \textbf{1} is more than half of \textbf{1} (the size of that pile). Assume that you and your friend play optimally and you play first, determine whether you have a winning move. You are said to have a winning move if after making that move, you can eventually win no matter what your friend does. \InputFile The first line of input contains an integer \textbf{T} (\textbf{T} ≤ \textbf{100}) denoting the number of testcases. Each testcase begins with an integer \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{100}) the number of piles. The next line contains \textbf{N} integers \textbf{a_1}, \textbf{a_2}, \textbf{a_3}, ..., \textbf{a_N} (\textbf{1} ≤ \textbf{a}_\{i \}≤_\{ \}\textbf{2·10^18}) the number of stones in each pile. \OutputFile For each testcase, print "\textbf{YES}" (without quote) if you have a winning move, or "\textbf{NO}" (without quote) if you don't have a winning move.
Time limit 3 seconds
Memory limit 64 MiB
Input example #1
4 
2 
4 4 
3 
1 2 3
3 
2 4 6
3 
1 2 1
Output example #1
NO
YES
NO
YES
Source ACM-ICPC 2010 Jakarta