HDU 2509--anti-nim

Source: Internet
Author: User

Topic:

Description

Let's consider M apples divided into n groups. Each group contains no more than to apples, arranged in a line. You can take any number of consecutive apples at one time.
For example "@@@" Can is turned into "@@" or "@" or "@ @" (both piles). People get apples one after another and the one takes
The loser. Fra wants to know in which situations he can win by playing strategies (that's, no matter what action the rival takes, FR A'll win).

Input

You'll be given several cases. Each test case begins with a single number n (1 < n <=), followed by a line with n numbers, the number of apples In each pile. There is a blank line between cases.

Output

If a winning strategies can be found, the print a single line with "Yes", otherwise print "No".

Sample Input

2 2 2) 1 3

Sample Output

No Yes Analysis: Anti-nim
1#include <cstdio>2 intMain ()3 {4     intn,a[ -],ans,flag;5      while(SCANF ("%d", &n) = =1)6     {7ans=0;8flag=1;9          for(intI=0; i<n;i++)Ten         { Onescanf"%d",&a[i]); A             if(a[i]!=1) flag=0; -ans^=A[i]; -         } the         if(flag) -         { -             if(n&1) -printf"no\n"); +             Else -printf"yes\n"); +         } A         Else at         { -             if(ANS) -printf"yes\n"); -             Else -printf"no\n"); -         } in     } -     return 0; to}
View Code

HDU 2509--anti-nim

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.