欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

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

发布时间:2025/7/25 编程问答 76 豆豆
生活随笔 收集整理的这篇文章主要介绍了 【BZOJ1022】小约翰的游戏(博弈论) 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

【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; }

转载于:https://www.cnblogs.com/cjyyb/p/9489585.html

总结

以上是生活随笔为你收集整理的【BZOJ1022】小约翰的游戏(博弈论)的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。