zoukankan      html  css  js  c++  java
  • 8.2.7 Be the Winner

    Be the Winner

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 38 Accepted Submission(s): 29

    Problem Description
    Let's consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time.
    For example "@@@" can be turned into "@@" or "@" or "@ @"(two piles). two people get apples one after another and the one who takes the last is
    the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).
     

    Input
    You will be given several cases. Each test case begins with a single number n (1 <= n <= 100), 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, print a single line with "Yes", otherwise print "No".
     

    Sample Input
    2
    2 2
    1
    3
     

    Sample Output
    No
    Yes

    anti-nim跟上一篇一样

    http://www.cnblogs.com/cssystem/p/3204826.html

     1 #include <cmath>
     2 #include <cstdio>
     3 #include <algorithm>
     4 #include <cstring>
     5 #include <string>
     6 #include <cstdlib>
     7 using namespace std;
     8 
     9 const int maxn=210;
    10 int n,ans,T,x;
    11 bool flag;
    12 
    13 void close()
    14 {
    15 exit(0);
    16 }
    17 
    18 
    19 void init()
    20 {
    21     while(scanf("%d",&n)!=EOF)
    22     {
    23         flag=false;
    24         scanf("%d",&ans);
    25         if (ans>1) flag=true;
    26         for (int i=2;i<=n;i++)
    27         {
    28             scanf("%d",&x);
    29             if (x>1) flag=true;
    30             ans=ans ^ x;
    31         }
    32         if (not flag) //全部是1
    33         {
    34             if (n % 2==0)
    35                 printf("Yes
    ");
    36             else
    37                 printf("No
    ");
    38         }
    39         else
    40         {        
    41             if (ans!=0)
    42                 printf("Yes
    ");
    43             else
    44                 printf("No
    ");
    45         }
    46     }
    47 }
    48 
    49 int main ()
    50 {
    51     init();
    52     close();
    53     return 0;
    54 }
  • 相关阅读:
    暑假快乐期刊(Android体温计特别篇)
    大二寒假作业之javaweb
    大二寒假作业之账本开发
    大二寒假作业之账本开发
    大二寒假作业之账本开发
    大二寒假作业之账本开发
    大二寒假作业之账本开发
    大二寒假作业之Android
    大二寒假作业之Android
    大二寒假作业之Android
  • 原文地址:https://www.cnblogs.com/cssystem/p/3212542.html
Copyright © 2011-2022 走看看