hdu-1907-反nim博弈
John
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 5793 Accepted Submission(s): 3358
Both of players are using optimal game strategy. John starts first always. You will be given information about M&Ms and your task is to determine a winner of such a beautiful game.
Constraints:
1 <= T <= 474,
1 <= N <= 47,
1 <= Ai <= 4747
3
3 5 1
1
1
Brother
#include<bits/stdc++.h>
using namespace std;
int main(){
int t,n,m;
cin>>t;
while(t--){
int a,sg=,tot=;
cin>>n;
for(int i=;i<=n;++i){
cin>>a;
sg^=a;
if(a==) tot++;
}
if( (tot==n&&sg==) || (tot!=n&&sg!=)) puts("John");
else puts("Brother");
}
return ;
}
hdu-1907-反nim博弈的更多相关文章
- HDU 1907 John nim博弈变形
John Problem Description Little John is playing very funny game with his younger brother. There is ...
- hdu2509Be the Winner(反nim博弈)
Be the Winner Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- hdu1907John(反nim博弈)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- LightOJ 1253 Misere NIM(反NIM博弈)
Alice and Bob are playing game of Misère Nim. Misère Nim is a game playing on k piles of stones, eac ...
- 反Nim博弈
原文地址:https://blog.csdn.net/xuejye/article/details/78975900 在尼姆博奕中取完最后一颗糖的人为赢家,而取到最后一颗糖为输家的就是反尼姆博奕.这道 ...
- hdu 1907 尼姆博弈
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- HDU 1907 John(博弈)
题目 参考了博客:http://blog.csdn.net/akof1314/article/details/4447709 //0 1 -2 //1 1 -1 //0 2 -1 //1 2 -1 / ...
- 博弈论中的Nim博弈
瞎扯 \(orzorz\) \(cdx\) 聚聚给我们讲了博弈论.我要没学上了,祝各位新年快乐.现在让我讲课我都不知道讲什么,我会的东西大家都会,太菜了太菜了. 马上就要回去上文化课了,今明还是收下尾 ...
- HDU 1907 Nim博弈变形
1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...
- hdu 1907 John&& hdu 2509 Be the Winner(基础nim博弈)
Problem Description Little John is playing very funny game with his younger brother. There is one bi ...
随机推荐
- Linux(CentOS)下同时启动两个tomcat
问题背景:在配置nginx时,配置了两个tomcat,tomcat01和tomcat02,改了tomcat02中server.xml的端口,可是还是启动不起来. 解决方法: 一.编辑环境变量: 1 v ...
- Qt中layout()->setSizeConstraint(QLayout::SetFixedSize);崩溃的问题
编译环境: win764位,vs2008编译器,cbd调试器,qt4.8 背景: 按照<C++ Gui Qt4编程>书中第二章的一个例子(sortDialog)一步步抄完,编译运行,显示不 ...
- C/C++之类型强制转化
强制转化四种类型可能很多人都常常忽略就象我一样,但是有时还是比较有用的.不了解的建议看看,一些机制我也不是十分了解,只是将一些用法写出来让大家看看. ...
- 【前端开发】利用Fiddler抓包工具进行本地调试
解决什么问题: 解决前端在本地联调页面 || 样式 || 脚本时经常修改服务器代码,浪费太多时间. 避免多人同时修改代码产生冲突问题.可以在本地调完代码之后,再贴到服务器上. 其实这个问题老早就开始想 ...
- P2503 [HAOI2006]均分数据
P2503 [HAOI2006]均分数据 模拟退火+dp (不得不说,我今天欧气爆棚) 随机出1个数列,然后跑一遍dp统计 #include<iostream> #include<c ...
- 静态编译C/C++程序
静态编译C/C++程序,让程序运行不受平台限制 由于Linux操作系统的特有elf加载顺序. (可以参考此文). 虽然可以很大程度上解决Windows早期版本的dll hell问题, 但是给部署带来了 ...
- c++获取时间戳
vc获取时间戳的代码如下: SYSTEMTIME st; }; GetLocalTime(&st); // vc专用 _snprintf_s(ts, sizeof(ts), "%4d ...
- 05: jQuery
目录: jQuery参考网站 W3school 1.1 JQuery作用 1.2 jQuery与DOM比较 与 相互转换 1.3 jQuery选择器 1.4 jQuery筛选与过滤 1.5 jQuer ...
- 开源项目托管GitHub
工具:本地HelloWorld源项目 msysgit(Windows) 实验步骤:一.在GitHub新建托管项目 在http://github.com注册账号20159214-sunnan. 完成注册 ...
- 使用node连接MongoDB数据 综本地及linux服务器记
gitee地址 启动mongo D:\MongoDB> ./bin/mongod --dbpath ./data/db MongoDB 提供了简单的 HTTP 用户界面. 如果你想启用该功能,需 ...