hdu 4994(博弈)
Revenge of Nim
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 562 Accepted Submission(s): 290
is a mathematical game of strategy in which two players take turns
removing objects from distinct heaps. On each turn, a player must remove
at least one object, and may remove any number of objects provided they
all come from the same heap.
---Wikipedia
Today, Nim takes
revenge on you. The rule of the game has changed a little: the player
must remove the objects from the current head(first) heap. Only the
current head heap is empty can the player start to remove from the new
head heap. As usual, the player who takes the last object wins.
Each
test case begins with an integer N, indicating the number of heaps.
Then N integer Ai follows, indicating the number of each heap
successively, and the player must take objects in this order, from the
first to the last.
[Technical Specification]
1. 1 <= T <= 100
2. 1 <= N <= 1 000
3. 1 <= Ai <= 1 000 000 000
1
2
2
1 1
No
/**
对于某个人来说,只要他能够取到第一个>1的堆,那么他就可以决定后面的人的状态了,所以第一个取到>1的堆的人
是赢家。所以我们只要讨论前面有多少==1的堆就行了。
2.如果里面存在>1的堆,那么在第一个>1的堆前面有偶数个=1的堆先手才会赢
1.如果没有>1的堆,那么奇数个=1的堆先手就会赢。
*/
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
typedef long long LL; int main()
{
int tcase;
scanf("%d",&tcase);
while(tcase--)
{
int n,cnt=,v;
bool flag = false;
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%d",&v);
if(v>&&!flag)
{
flag = true;
cnt = i-;
}
}
if(!flag) cnt = n;
if(flag){
if(cnt%==) printf("No\n");
else printf("Yes\n");
}else{
if(cnt%==) printf("No\n");
else printf("Yes\n");
}
}
return ;
}
hdu 4994(博弈)的更多相关文章
- HDU 4994 博弈。
F - 6 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- Revenge of Nim hdu 4994 (博弈)
http://acm.split.hdu.edu.cn/showproblem.php?pid=4994 题意:现在有两个人在取石子,共有n堆石子,每堆石子取完后才可以取下一堆石子,最后一个取石子的人 ...
- S-Nim HDU 1536 博弈 sg函数
S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...
- HDU - 4994 Revenge of Nim (取石子游戏)
Problem Description Nim is a mathematical game of strategy in which two players take turns removing ...
- hdu 4994 前后有序Nim游戏
http://acm.hdu.edu.cn/showproblem.php?pid=4994 Nim游戏变成从前往后有序的,谁是winner? 如果当前堆数目为1,玩家没有选择,只能取走.遇到到不为1 ...
- BestCoder8 1002 Revenge of Nim(hdu 4994) 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4994 题目意思:有 n 个 heap(假设从左至右编号为1-n),每个 heap 上有一些 objec ...
- HDU 5996 博弈
http://acm.hdu.edu.cn/showproblem.php?pid=5996 博弈论待补. 这题变化了一下,因为注意到奇数层的东西(层数从1开始),对手可以模仿地动,那就相当于没动. ...
- A - 无聊的游戏 HDU - 1525(博弈)
A - 无聊的游戏 HDU - 1525 疫情当下,有两个很无聊的人,小A和小B,准备玩一个游戏,玩法是这样的,从两个自然数开始比赛.第一个玩家小A从两个数字中的较大者减去两个数字中较小者的任何正倍数 ...
- hdu 1517 博弈 **
博弈题: 题意:2 个人玩游戏,从 1 开始,轮流对数进行累乘,直到超过一个指定的值. 解题思路:如果输入是 2 ~ 9 ,因为Stan 是先手,所以Stan 必胜如果输入是 10~18 ,因为Oll ...
随机推荐
- 菜鸟学Linux - bash的配置文件
bash是各大Linux发行版都支持的shell.当我们登陆bash的时候,虽然我们什么都没做,但是我们已经可以在bash中调用各种各样的环境变量了.这是因为,系统中已经定义了一系列的配置文件,以及加 ...
- CyclicBarrier源码分析
CyclicBarrier是通过ReentrantLock(独占锁)和Condition来实现的.下面,我们分析CyclicBarrier中3个核心函数: 构造函数, await()作出分析. 1. ...
- Kali 远程登陆SSH
一.配置SSH 编辑/etc/ssh/sshd_config 将#PasswordAuthentication no的注释去掉,将NO修改为YES //可以用密码登陆 将PermitRootLogin ...
- excel VBA 将文本数值转换为数字格式(单元格中数据左上角是绿三角,鼠标点上有叹号标示)
Range("A6").SelectSelection.CopyRange("A10:A60").SelectRange(Selection, Selectio ...
- java高级编程技巧
1. boolean a= b==null;这句话很亮. public class Test { public static void main(String[] args) { String b=& ...
- Marketing learning-2
Part three 1.strategies for leadership 1)operational excellence:operational competence 2)performance ...
- mini购物车程序
product_list=[("Iphohe",5800),("Mac Pro Book",12900), ("xiaomi 4c",120 ...
- Python对文本文件的简单操作(一)
工作背景 性能测试工程师,主要测试工具--loadrunner,主要是接口测试. 实现功能 loadrunner对报文格式的转换存在问题,部分报文无法转换,故使用Python编写脚本自动将soap协议 ...
- ThinkPHP5 配置文件
配置目录 系统默认的配置文件目录就是应用目录(APP_PATH),也就是默认的application下面,并分为应用配置(整个应用有效)和模块配置(仅针对该模块有效). ├─application 应 ...
- maven学习(六)——在别的项目中引用通过Maven安装生成的项目的jar包
1.新建HelloFriend项目,同时建立Maven约定的目录结构和pom.xml文件 HelloFriend | --src | -----main | ----------java | - ...