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