hdu 1907——John & hdu 2509——Be the Winner

来源:互联网 发布:犀牛软件 垃圾袋 编辑:程序博客网 时间:2024/06/11 09:50

1907:

题意:几堆珠子,每次可以去一堆中的若干个。取到最后一个珠子的人输。问先手能否赢

代码如下:

#include<cstdio>#include<iostream>#include<cstring>using namespace std;int main(){  //  freopen("data.txt","r",stdin);    int T;    scanf("%d",&T);    while(T--)    {        int n;        scanf("%d",&n);        int d=0;        int p=0;        for(int i=0;i<n;++i)        {            int a;            scanf("%d",&a);            d=d^a;            if(a>=2)p++;        }        if((d==0&&p>=2)||(d&&p==0))puts("Brother");        else puts("John");    }return 0;}

2509:

题意:跟上一题一模一样

代码:

#include<cstdio>#include<iostream>#include<cstring>using namespace std;int main(){  //  freopen("data.txt","r",stdin);    int n;    while(scanf("%d",&n)!=EOF)    {        int d=0;        int p=0;        for(int i=0;i<n;++i)        {            int a;            scanf("%d",&a);            d=d^a;            if(a>=2)p++;        }        if((d==0&&p>=2)||(d&&p==0))puts("No");        else puts("Yes");    }return 0;}


0 0
原创粉丝点击