首页 > 其他 > 详细

【BZOJ1022】小约翰的游戏(博弈论)

时间:2018-08-16 20:49:14      阅读:181      评论:0      收藏:0      [点我收藏+]

【BZOJ1022】小约翰的游戏(博弈论)

题面

BZOJ

题解

\(Anti-SG\)游戏的模板题目。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
#define RG register
inline int read()
{
    RG int x=0,t=1;RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=-1,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return x*t;
}
int n;
bool check()
{
    n=read();bool One=true;
    int X=0;
    for(int i=1;i<=n;++i)
    {
        int x=read();
        if(x^1)One=false;
        X^=x;
    }
    if(One)return X==0;
    else return X;
}
int main()
{
    int T=read();
    while(T--)
        check()?puts("John"):puts("Brother");
    return 0;
}

【BZOJ1022】小约翰的游戏(博弈论)

原文:https://www.cnblogs.com/cjyyb/p/9489585.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!