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 }
  • 相关阅读:
    jQuery技巧总结
    IBatis.NET框架
    武林足球Ajax全站的核心JS
    Lucene入门与使用(2)转
    图片预加载
    构建基于词典的Lucene分析器
    利用system表来注入
    查看执行后的HTML代码,方便调试
    每日英语
    关于URL的地址重写,自己也实验了一把!
  • 原文地址:https://www.cnblogs.com/cssystem/p/3212542.html
Copyright © 2011-2022 走看看