zoukankan      html  css  js  c++  java
  • 博弈--hdu1907/2509

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1907

    此题应多看http://blog.sina.com.cn/s/blog_9d987af5010154wv.html这里的博客,用心看其实很简单。

    以及这里的博客:http://blog.csdn.net/longshuai0821/article/details/6669777

    #include <stdio.h>
    int main()
    {
        int n,m,i,j;
        int co[5000];
        scanf("%d",&n);
        while(n--)
        {
            scanf("%d",&m);
            for(i=0;i<m;i++)
            {
                scanf("%d",&co[i]);
            }
            int sum=0,x=0;
            for(i=0;i<m;i++)
            {
                sum^=co[i];
                if(co[i]>=2)
                    x++;
            }
            if(x==0&&sum!=0||x>=2&&sum==0)
                printf("Brother
    ");
            else printf("John
    ");
    
        }
    }

    hdu2509的代码,基本一样

    #include <stdio.h>
    int main()
    {
        int n,m,i,j;
        int co[5000];
    
        while(scanf("%d",&m)!=EOF)
        {
            for(i=0;i<m;i++)
            {
                scanf("%d",&co[i]);
            }
            int sum=0,x=0;
            for(i=0;i<m;i++)
            {
                sum^=co[i];
                if(co[i]>=2)
                    x++;
            }
            if(x==0&&sum!=0||x>=2&&sum==0)
                printf("No
    ");
            else printf("Yes
    ");
    
        }
    }
    

      

  • 相关阅读:
    【POJ2311】Cutting Game-SG博弈
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
  • 原文地址:https://www.cnblogs.com/ccccnzb/p/hdu1907--2509.html
Copyright © 2011-2022 走看看