zoukankan      html  css  js  c++  java
  • hdu-2509-反nim博弈

    Be the Winner

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


    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
     
    Source
     

       一开始没注意到0态是胜态这个条件,想成sg来做了,结果WA。

       这个题目参考1709的证明过程,不同的地方在于这个可以将一堆取走一部分之后再把剩下的分成两堆,有趣啊,

    但是按照上述证明即使有这个条件依然不影响结论的正确性,所以可以直接套用。

      

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int main(){
     4     int t,n,m;
     5     while(cin>>n){
     6         int a,sg=0,tot=0;
     7         for(int i=1;i<=n;++i){
     8             cin>>a;
     9             sg^=a;
    10             if(a==1) tot++;
    11         }
    12         if( (tot==n&&sg==0) || (tot!=n&&sg!=0)) puts("Yes");
    13         else puts("No");
    14     }
    15     return 0;
    16 }
  • 相关阅读:
    虚拟化碎片知识
    CentOS升级内核及KVM安装(已试验,可行)
    Libvirt 虚拟化库剖析
    [ACM]Max Sum
    [ACM]n a^o7 !
    [java]ActionEvent事件:获取输入字符串的长度
    [ACM]The Best Seat in ACM Contest
    [java]ItemEvent事件:简单计算器
    通过注册表的句柄得到当前句柄在注册表中的路径
    [测试模式]Setup方法的滥用
  • 原文地址:https://www.cnblogs.com/zzqc/p/9349904.html
Copyright © 2011-2022 走看看