Uvalive 5059 c-playing with stones game theory sg function

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.