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 / ...
随机推荐
- [HDU5001]Walk
Problem Description I used to think I could be anything, but now I know that I couldn't do anything. ...
- LeetCode初级算法--排序和搜索01:第一个错误的版本
LeetCode初级算法--排序和搜索01:第一个错误的版本 搜索微信公众号:'AI-ming3526'或者'计算机视觉这件小事' 获取更多算法.机器学习干货 csdn:https://blog.cs ...
- jmeter-中文乱码问题
1.被测系统中问乱码 解决办法:接口请求时添加编码方式UTF-8
- 入门了解Service Mesh + Istio?从本文开始
下周六,深圳,阔别已久的线下技术沙龙要和你见面啦! 现场有Rancher Labs研发经理demo刚刚发布的Rancher 2.3中的Istio.Windows容器.集群模板等功能及使用,还有k3s首 ...
- 百万年薪python之路 -- MySQL数据库之 MySQL行(记录)的操作(一)
MySQL的行(记录)的操作(一) 1. 增(insert) insert into 表名 value((字段1,字段2...); # 只能增加一行记录 insert into 表名 values(字 ...
- 手把手实现微信网页授权和微信支付,附源代码(VUE and thinkPHP)
wechat github 手把手实现微信网页授权和微信支付,附源代码(VUE and thinkPHP) 概述 公众号开发是痛苦的,痛苦在好多问题开发者文档是没有提到的,是需要你猜的. 在开发过程中 ...
- DOS批量重命名
下面有一些文件:dir /b *.*得到 144-10.1.4.150-1484707792127 2326-10.1.4.150-1484708376194 3682-10.1.4.150-1484 ...
- SpringBoot与MybatisPlus3.X整合示例(十六)
包含 分页.逻辑删除.自定义全局操作 等绝大部分常用功能的使用示例,相当于大整合的完整示例 pom.xml <dependencies> <dependency> <gr ...
- python基础-流程控制(if,while,for)
今日内容总结 --流程控制(if,while,for) if:用来判断事物的对错.真假.是否执行.根据不同的情况判断,条件满足执行某条件下的语句 语法结构(3种) # 第一种,只有if结构.条件表达式 ...
- csp-s模拟测试101的T3代码+注释
因为题目过于大神所以单独拿出来说.而且既然下发std了颓代码貌似也不算可耻233 很难讲啊,所以还是写在代码注释里面吧 因为比较认真的写了不少注释,所以建议缩放到80%观看,或者拿到gedit上 1 ...