John
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 4704 Accepted Submission(s): 2720
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;
int n;
int a;
int i;
int sum, ones; scanf("%d", &t); while (t--) {
scanf("%d", &n);
sum = , ones = ;
for (i = ; i < n; ++i) {
scanf("%d", &a);
sum ^= a;
if (a == ) {
++ones;
}
} //win : t0, s1, s2
//lose : s0, t2
if (sum == ) {//t
if (n - ones == ) {//t0
printf("John\n");
} else {//t2
printf("Brother\n");
}
} else {//s
if (n - ones == ) {//s0
printf("Brother\n");
} else {//s1, s2
printf("John\n");
}
}
} return ;
}
hdu 1907 John(anti nim)的更多相关文章
-
hdu 1907 John (anti—Nim)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)http://acm.h ...
-
HDU 1907 John (Nim博弈)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
-
POJ 3480 &;amp; HDU 1907 John(尼姆博弈变形)
题目链接: PKU:http://poj.org/problem? id=3480 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1907 Descri ...
-
HDU 1907 John(博弈)
题目 参考了博客:http://blog.csdn.net/akof1314/article/details/4447709 //0 1 -2 //1 1 -1 //0 2 -1 //1 2 -1 / ...
-
HDU 1907 John(取火柴博弈2)
传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...
-
hdu 2509 Be the Winner(anti nim)
Be the Winner Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
-
HDU 5795 A Simple Nim(简单Nim)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
-
HDU 3533 Escape(大逃亡)
HDU 3533 Escape(大逃亡) /K (Java/Others) Problem Description - 题目描述 The students of the HEU are maneu ...
-
HDU 1043 Eight(八数码)
HDU 1043 Eight(八数码) 00 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Descr ...
随机推荐
-
Java Statement和PreparedStatement性能测试(转)
本文转载自http://blog.csdn.net/liubo5005/article/details/7239935 先上代码: import java.sql.Connection; import ...
-
bower install和cnpm install
bower install :主要是安装前端的相关框架,如Boostarp,Angular等 cnpm install :主要是安装后端的,如express等
-
rac安装oem
[oracle@node1 ~]$ emca -config dbcontrol db -repos recreate -cluster STARTED EMCA at May 31, 2016 3: ...
-
No DEFAULT or UI configuration directive found!
虚拟机安装OracleLinux出错: No DEFAULT or UI configuration directive found! 解决方法:我使用第一条就成功了 在报错信息后面的boot命令行输 ...
-
20155214&;20155216 实验二:固件程序设计
---恢复内容开始--- 20155214&20155216 实验二:固件程序设计 实验内容及要求 实验二 固件程序设计-1-MDK 实验要求: 1.注意不经老师允许不准烧写自己修改的代码 2 ...
-
[LeetCode] Transform to Chessboard 转为棋盘
An N x N board contains only 0s and 1s. In each move, you can swap any 2 rows with each other, or an ...
-
设置placeholder无效解决办法
一.设置placeholder的方法 placeholder属性用来设置控件内部的提示信息 <input type="text" placeholder="请输入用 ...
-
2.3.7synchronized代码块有volatile同步的功能
关键字synchronized可以使多个线程访问同一个资源具有同步性,而且他还具有将线程工作内存中的私有变量与公共内存中的变量同步的功能. package com.cky.thread; /** * ...
-
jmap dump文件压缩后失效
最近线上出问题,于是用jmap -dump拿到dump文件,再linux压缩后拿到windows下无效,后来又直接拿了一个没有压缩的竟然可以用...坑啊!~
-
ASP.NET MVC异常处理方案
异常处理是每一个系统都必须要有的功能,尤其对于Web系统而言,简单.统一的异常处理模式尤为重要,当打算使用ASP.NET MVC来做项目时,第一个数据录入页面就遇到了这个问题. 在之前的ASP.NET ...