hdu 1907 John (尼姆博弈)
John
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 6000 Accepted Submission(s): 3486
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
2
3
3 5 1
1
1
John
Brother
C/C++:
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
#define INF 0x3f3f3f3f
#define LL long long
#define wzf ((1 + sqrt(5.0)) / 2.0)
using namespace std;
const int MAX = ; int n, t, num[MAX], temp; int main()
{
scanf("%d", &t);
while (t --)
{
scanf("%d", &n);
for (int i = ; i < n; ++ i)
scanf("%d", &num[i]);
sort(num, num + n);
if (num[n - ] == )
{
if (n & ) printf("Brother\n");
else printf("John\n");
continue;
}
temp = num[] ^ num[];
for (int i = ; i < n; ++ i)
temp ^= num[i];
if (temp == )
printf("Brother\n");
else
printf("John\n");
}
return ;
}
hdu 1907 John (尼姆博弈)的更多相关文章
- hdu 1907 (尼姆博弈)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1907 Problem Description Little John is playing very ...
- hdu 1849 (尼姆博弈)
http://acm.hdu.edu.cn/showproblem.php? pid=1849 简单的尼姆博弈: 代码例如以下: #include <iostream> #include ...
- HDU 1907 John (Nim博弈)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- John 尼姆博弈
John Little John is playing very funny game with his younger brother. There is one big box filled wi ...
- HDU - 1907 John 反Nimm博弈
思路: 注意与Nimm博弈的区别,谁拿完谁输! 先手必胜的条件: 1. 每一个小游戏都只剩一个石子了,且SG = 0. 2. 至少有一堆石子数大于1,且SG不等于0 证明:1. 你和对手都只有一种选 ...
- POJ 3480 & HDU 1907 John(尼姆博弈变形)
题目链接: PKU:http://poj.org/problem? id=3480 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1907 Descri ...
- hdu 1907 尼姆博弈
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- HDU.1850 being a good boy in spring festival (博弈论 尼姆博弈)
HDU.1850 Being a Good Boy in Spring Festival (博弈论 尼姆博弈) 题意分析 简单的nim 博弈 博弈论快速入门 代码总览 #include <bit ...
- HDU 1907 John(博弈)
题目 参考了博客:http://blog.csdn.net/akof1314/article/details/4447709 //0 1 -2 //1 1 -1 //0 2 -1 //1 2 -1 / ...
随机推荐
- 数据挖掘:关联规则的apriori算法在weka的源码分析
相对于机器学习,关联规则的apriori算法更偏向于数据挖掘. 1) 测试文档中调用weka的关联规则apriori算法,如下 try { File file = new File("F:\ ...
- [BZOJ1694/1742/3074]The Cow Run 三倍经验
Description John养了一只叫Joseph的奶牛.一次她去放牛,来到一个非常长的一片地,上面有N块地方长了茂盛的草.我们可 以认为草地是一个数轴上的一些点.Joseph看到这些草非常兴奋, ...
- 使用WSL中开发调试.NET Core
安装WSL 1.打开WINDOWS功能,勾选子系统选项 2.打开商店搜索WSL,安装ubuntu 我这里的系统版本是:18.04 如何查看ubuntu系统版本 sudo lsb_release -a ...
- halcon小结
持更 应用范围 (罗列自官方帮助文档,以后有空了按照需求展开叙述) 1. 安全系统 2. 表面检测 3. 定位 4. 二维测量比较 5. 二维码识别 6. 二维位置定位 7. 二维物体识别 8. 光学 ...
- Bugku SQL注入2的思考
网络安全初学者,欢迎评论交流学习,若内容中有错误欢迎各位指正. 题目地址:http://123.206.87.240:8007/web2/ 题目提示:都过滤了绝望吗?,提示 !,!=,=,+,-,^, ...
- springboot 打jar包时分离配置文件
修改pom.xml文件 <build> <resources> <resource> <directory>src/main/resources< ...
- Springboot与任务整合(四)
一 异步任务 启动类 @MapperScan("com.topcheer.*.*.dao") @SpringBootApplication @EnableCaching @Enab ...
- Scrapy 之settings配置
BOT_NAME 默认: 'scrapybot' 当您使用 startproject 命令创建项目时其也被自动赋值. ROBOTSTXT_OBEY = False 是否遵守rebotes.txt协议 ...
- 四、docker 仓库(让我们的镜像有处可存)
前言 前面讲完了docker 镜像和容器,以及通过Dockerfile 定制属于我们自己的镜像,那那现在就是需要将我们自己定制的镜像存放到仓库中供他们使用.这一套流程才算是正式走完了.从获取镜像,操作 ...
- 大觅网05Day
1.Mycat概述 在此前的服务器对数据库的存储数量要求并不高的时候,被经常使用的MySql数据基本能够满足对数据存储的要求. 但随着技术的不断发展,MySql甚至Redis都无法满足现今存储数量的指 ...