【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】小约翰的游戏(博弈论)的更多相关文章

  1. BZOJ 1022 Luogu P4279 [SHOI2008]小约翰的游戏 (博弈论)

    题目链接: (bzoj) https://www.lydsy.com/JudgeOnline/problem.php?id=1022 (luogu) https://www.luogu.org/pro ...

  2. [Bzoj1022][SHOI2008]小约翰的游戏John(博弈论)

    1022: [SHOI2008]小约翰的游戏John Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2976  Solved: 1894[Submit] ...

  3. [bzoj1022/poj3480]小约翰的游戏John_博弈论

    小约翰的游戏John 题目大意:Nim游戏.区别在于取走最后一颗石子这输. 注释:$1\le cases \le 500$,$1\le n\le 50$. 想法:anti-SG游戏Colon定理. 如 ...

  4. BZOJ1022 [SHOI2008]小约翰的游戏John 【博弈论】

    1022: [SHOI2008]小约翰的游戏John Time Limit: 1 Sec  Memory Limit: 162 MB Submit: 3014  Solved: 1914 [Submi ...

  5. BZOJ_1022_[SHOI2008]_小约翰的游戏John_(博弈论_反Nim游戏)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1022 反Nim游戏裸题.详见论文<组合游戏略述——浅谈SG游戏的若干拓展及变形>. ...

  6. bzoj千题计划112:bzoj1022: [SHOI2008]小约翰的游戏John

    http://www.lydsy.com/JudgeOnline/problem.php?id=1022 http://www.cnblogs.com/TheRoadToTheGold/p/67448 ...

  7. bzoj1022: [SHOI2008]小约翰的游戏John(博弈SG-nim游戏)

    1022: [SHOI2008]小约翰的游戏John 题目:传送门 题目大意: 一道反nim游戏,即给出n堆石子,每次可以取完任意一堆或一堆中的若干个(至少取1),最后一个取的LOSE  题解: 一道 ...

  8. BZOJ 1022 [SHOI2008]小约翰的游戏John

    1022: [SHOI2008]小约翰的游戏John Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 1635  Solved: 1036[Submit] ...

  9. 1022: [SHOI2008]小约翰的游戏John

    1022: [SHOI2008]小约翰的游戏John Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 1322  Solved: 829[Submit][ ...

随机推荐

  1. PEP 8 python编程规范

    一 代码编排 缩进.4个空格的缩进(编辑器都可以完成此功能),不使用Tap,更不能混合使用Tap和空格. 每行最大长度79,换行可以使用反斜杠,最好使用圆括号.换行点要在操作符的后边敲回车. 类和to ...

  2. linux中mariadb的安装

    在Linux中mariaDB的安装 MariaDB其实就是MySQL的分支,是为了应对MySQL的即将的闭源风险所产生的. Linux系统中软件包的格式为mysql.rpm格式. 通过yum去安装 L ...

  3. 会议室预订系统(meeting room booking system)

    一.mrbs mrbs:(meeting room booking system) 二.效果   三.models from django.db import models # Create your ...

  4. Oracle 表分区(Partition)

    表分区功能能够改善应用程序性能,提高数据库可管理性和可用性,是数据库管理非常关键的技术.数据库通过使用分区提高查询性能,简化日常管理维护工作. 1 分区优点 1) 减少维护工作量,独立管理每个表分区比 ...

  5. java从request中获取GET和POST请求参数

    URL和参数列表 一 获取请求方式 request.getMethod(); get和post都可用, 二 获取请求类型 request.getContentType(); get和post都可用,示 ...

  6. C# Note14: Editable WPF ListView

    (1)https://stackoverflow.com/questions/5652527/editable-wpf-listview (2)How to: Create a ListView wi ...

  7. 原生JS实现增加删除class

    <!DOCTYPE html> <html> <head> <style type="text/css"> .night-mode{ ...

  8. 用python写一个预警机器人(支持微信和钉钉)

    背景 线上的系统在运行中,发生故障时怎么及时的通过手机通知到相关人员?当然这是个很简单的需求,现有的方法有很多,例如: 如果我们用的云产品,那么一般都会有配套对应的监控预警功能,根据需要配置一下即可, ...

  9. Python——Flask框架——模板

    一.渲染模板 render_template 函数把Jinja2模板引擎集成到程序中 二.Jinja2变量过滤器 过滤器名 说明 safe 渲染值是不转义 capitalize 把值得首字母转换成大写 ...

  10. springboot+jpa+mysql+swagger整合

    Springboot+jpa+MySQL+swagger整合 创建一个springboot web项目 <dependencies> <dependency>      < ...