c-playing with stonesTime
limit:3000MS
Memory Limit:0KB
64bit IO Format:%lld &%lluSubmit Status Practice uvalive 5059
Description
You and your friend is playing a game in which, and your friend take turns removing stones from piles. Initially there is N piles with a 1, a 2, a 3, ..., a N number of stones. On each turn, a-player must remove at least one stone from one pile and no more than half of the number of stones Pile. The player cannot make any moves is considered lost. For example, if there is three piles with 5, 1 and 2 stones, then the player can take 1 or 2 stones from first pile, no s Tone from second pile, and only 1 stone from third pile. Note that the player cannot take any stones from the second pile as 1 are more than half of 1 (the size of that pile). Assume, your friend play optimally and you play first, determine whether your have a winning move. You is said to has a winning move if after making that move and you can eventually win no matter what your friend does.
Input
The first line of input contains an integer t(t) denoting the number of testcases. Each testcase begins with an integer n(1N) The number of piles. The next line contains n integers a1, a2, a3,..., an (1ai2 * 1018) The number of stones in each pile.
Output
For each testcase, the print 'YES' (without quote) If you have a winning move, or 'NO' (without quote) If you don?t has a winning move.
Sample Input
4 2 4 4 3 1 2 33 2 4 63 1 2 1
Sample Output
No Yes No Yes
intN;intMain () {intT; scanf ("%d",&t); while(t--) {scanf ("%d",&N); Long LongCnt=0; while(n--){ Long Longx; scanf ("%lld",&x); if(x==1)Continue; while(x&1) x/=2; CNT^=x/2; } if(cnt>0) printf ("yes\n"); Elseprintf"no\n"); } return 0;}
Uvalive 5059 c-playing with stones game theory sg function