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 ;
}
最新文章
- Permit.js – 用于构建多状态原型的 jQuery 插件
- Android内容观察者
- wget的使用详解
- 聊聊HTTPS和SSL_TLS协议
- C++不完整的类型
- Codeforces Round #247 (Div. 2) C题
- hdu 5264 pog loves szh I 水题
- SQLserver中的xp_cmdshell
- Could not parse mapping document from resource cn/spt/model/Student.hbm.xml
- android滑动删除的多种实现方式(一)
- The Time in Words
- 你真的会玩SQL吗?透视转换
- 斐波那契数列第n项的值及前n项之和
- sed 命令简介
- HDU6011
- phpstorm 找到文件修改历史
- Struts vs spring mvc
- 定时任务 Wpf.Quartz.Demo.5 (升级版)
- Python 3 进阶 —— print 打印和输出
- [Selenium.2.Testing.Tools.Beginners.Guide]读书笔记