hdu 1907 John(anti nim)
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 & 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 ...
随机推荐
- Linux查找命令find、locate、whereis、which、type
find:查找指定下目录的文件 -empty:查找空文件 -name:按名字查找 -type f(文件 or d:目录):按类型查找
- Pycharm中SQL语句提示SQL Dialect is Not Configured
解决办法: 在File---->Setting--->Languages & Frameworks--->SQL Dialects中,选择对应的数据库,如MySQL,之后点击 ...
- C# 函数4
//数据库 public class GF_DA { /// <summary> /// 执行SQL语句 sConnStr 连接字符串,sq ...
- LeetCode-day03
28. Best Time to Buy and Sell Stock 买卖股票的最好时间 29. Best Time to Buy and Sell Stock II 买卖股票2(多次买入,一次卖出 ...
- 剑指offer 面试26题
面试26题: 题目:树的子结构 题:输入两棵二叉树A和B,判断B是不是A的子结构. 解题思路:递归,注意空指针的情况. 解题代码: # -*- coding:utf-8 -*- # class Tre ...
- 剑指offer 面试63题
面试63题 题目:股票的最大利润 题:假设把某股票的价格按照时间先后顺序存储在数组中,请问买卖该股票一次可获得的最大利润是多少?例如,一只股票在某些时间节点的价格为{9,11,8,5,7,12,16, ...
- 初学JQuery相关知识点
[简单的JQuery]注册事件的函数. $(document).ready(function(){}) [JQuery提供的函数]$.map(array,fn) 对数组array中每个元素调用fn函数 ...
- 0802 DRF 视图
昨日回顾: 1. Serializer(序列化) 1. ORM对应的query_set和ORM对象转换成JSON格式的数据 1. 在序列化类中定义自定义的字段:SerializerMethodFiel ...
- 跨平台移动开发_PhoneGap 使用Accelerometer 加速器
使用Accelerometer 加速器效果图 示例代码 <!DOCTYPE html> <html> <head> <title> Cude Phone ...
- 三 ip dns等配置
一IP.端口.协议基本概念 ip的简单概念 互联网上的计算机,都会有一个唯一的32位的地址,ip地址 我们访问服务器,就必须通过ip地址 局域网里也有预留的ip地址 192/10/172.居于王的i ...