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 / ...
随机推荐
- React Diff算法一览
前言 diff算法一直是React系统最核心的部分,并且由于演化自传统diff,使得比较方式从O(n^3)降级到O(n),然后又改成了链表方式,可谓是变化万千. 传统Diff算法 传统diff算法需要 ...
- caffe中softmax源码阅读
(1) softmax函数 (1) 其中,zj 是softmax层的bottom输入, f(zj)是softmax层的top输 ...
- java架构之路-(Redis专题)聊聊大厂那些redis
上几次说了redis的主从,哨兵,集群配置,但是内部的选举一直没说,先来简单说一下选举吧. 集群选举 redis cluster节点间采取gossip协议进行通信,也就是说,在每一个节点间,无论主节点 ...
- RGB颜色值
- mysql库表优化实例
一.SQL优化 1.优化SQL一般步骤 1.1 查看SQL执行频率 SHOW STATUS LIKE 'Com_%'; Com_select:执行SELECT操作的次数,一次查询累加1.其他类似 以下 ...
- 5.分析snkrs的Android的DeviceID生产规则
分析Android的DeviceID生产 前面已经把web端的分析了一些,要想实现其实容易也难,容易是规则很容易,难是时间生成控制很难,我之前大概花了一周时间分析和梳理,然后行为测试,之前我已经讲过c ...
- mysql慢日志分析组件安装
1.pt-query-digest 安装 cd /usr/bin wget percona.com/get/pt-query-digest chmod u+x pt-query-digest yum ...
- Redis(十五)Redis 的一些常用技术(Spring 环境下)
一.Redis 事务与锁机制 1.Redis的基础事务 在Redis中开启事务的命令是 multi 命令, 而执行事务的命令是 exec 命令.multi 到 exec 命令之间的 Redis 命令将 ...
- (二)django--带APP的网站
1.打开终端,进入到django项目,创建APP应用:python manage.py startapp news 2.在settings.py中进行注册 3.在news下新建views.py,和ur ...
- SpringBoot整合MybatisPlus3.X之Wrapper(五)
官方文档说明: 以下出现的第一个入参boolean condition表示该条件是否加入最后生成的sql中 以下代码块内的多个方法均为从上往下补全个别boolean类型的入参,默认为true 以下出现 ...