网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  bzoj 1022: [SHOI2008]小约翰的游戏John【anti-nim】

bzoj 1022: [SHOI2008]小约翰的游戏John【anti-nim】

分类: IT文章 • 2024-10-11 15:12:01

如果全是1,那么n是奇数先手必败
否则,xor和为0先手必败
证明见 https://www.cnblogs.com/Wolfycz/p/8430991.html

#include<iostream>
#include<cstdio>
using namespace std;
const int N=55;
int T,n,a[N];
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		int x=0,fl=1;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			x^=a[i];
			if(a[i]!=1)
				fl=0;
		}
		if(fl)
			(n&1)?puts("Brother"):puts("John");
		else
			x?puts("John"):puts("Brother");
	}
	return 0;
}

相关推荐

  • BZOJ 1022: [SHOI2008]小约翰的游戏John
  • BZOJ 1022: [SHOI2008]小约翰的游戏John
  • bzoj 1022 小约翰的游戏John
  • BZOJ.1022.[SHOI2008]小约翰的游戏John(博弈论 Anti-Nim)
  • bzoj 1022: [SHOI2008]小约翰的游戏John【anti-nim】
  • bzoj1022: [SHOI2008]小约翰的游戏John
  • [bzoj1022][SHOI2008]小约翰的游戏 John (博弈论)
  • BZOJ 1022 [SHOI2008]小约翰的游戏John
  • 【BZOJ1022】小约翰的游戏(博弈论) 【BZOJ1022】小约翰的游戏(博弈论)
  • 洛谷 P4279 [SHOI2008]小约翰的游戏 解题报告 P4279 [SHOI2008]小约翰的游戏
  • poj 2960 S-Nim【SG函数】
  • bzoj 3513: [MUTC2013]idiots【生成函数+FFT】
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号