<span style="color: green; font-family: Arial; font-size: 12px; background-color: rgb(255, 255, 255);">Daizhenyang's Coin
</span>
<span style="color: green; font-family: Arial; font-size: 12px; background-color: rgb(255, 255, 255);">Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)</span>

Total Submission(s): 320    Accepted Submission(s): 146

Problem Description
We know that Daizhenyang is chasing a girlfriend. As we all know, whenever you chase a beautiful girl, there'll always be an opponent, or a rival. In order to take one step ahead in this chasing process, Daizhenyang decided to prove
to the girl that he's better and more intelligent than any other chaser. So he arranged a simple game: Coin Flip Game. He invited the girl to be the judge.

In this game, n coins are set in a row, where n is smaller than 10^8. They took turns to flip coins, to flip one coin from head-up to tail-up or the other way around. Each turn, one can choose 1, 2 or 3 coins to flip, but the rightmost selected must be head-up
before flipping operation. If one cannot make such a flip, he lost.

As we all know, Daizhenyang is a very smart guy (He's famous for his 26 problems and Graph Theory Unified Theory-Network Flow does it all ). So he will always choose the optimal strategy to win the game. And it's a very very bad news for all the competitors.

But the girl did not want to see that happen so easily, because she's not sure about her feelings towards him. So she wants to make Daizhenyang lose this game. She knows Daizhenyang will be the first to play the game. Your task is to help her determine whether
her arrangement is a losable situation for Daizhenyang.

For simplicity, you are only told the position of head-up coins. And due to the girl's complicated emotions, the same coin may be described twice or more times. The other coins are tail-up, of course.

Coins are numbered from left to right, beginning with 0.
 
Input
Multiple test cases, for each test case, the first line contains only one integer n (0<=n<=100), representing the number of head-up coins. The second line has n integers a1, a2 … an (0<=ak<10^8) indicating the An-th coin is head up.
 
Output
Output a line for each test case, if it's a losable situation for Daizhenyang can, print "Yes", otherwise output "No" instead.
 
Sample Input
0
1
0
4
0 1 2 3
 
Sample Output
Yes
No
Yes
翻硬币的经典例子-MOCK-TURTLES
打表发现:
x: 0 1 2 3 4 5 6 7...
g(x): 1 2 4 7 8 11 13 14...
发现x化作2进制1的个数为奇数时。g(x)= 2*x 否则 g(x) = 2*x+1 SG和即是答案。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;
int n;
set<int>st;
int main(){ while(~scanf("%d",&n)){
int ans = 0;
st.clear();
for(int i = 0; i < n; i++){
int t;
scanf("%d",&t);
if(st.count(t)==0){
if(t==0) ans ^= 1;
else{
int k = t,cnt = 0;
while(k){
k = k&(k-1);
cnt++;
}
if(cnt%2==0) ans ^= (2*t+1);
else ans ^= 2*t; }
st.insert(t);
} }
if(ans==0){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
return 0;
}

HDU3537-Daizhenyang&#39;s Coin(博弈SG-打表)的更多相关文章

  1. 51nod_1714:B君的游戏(博弈 sg打表)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1714 nim游戏的一个变形,需要打出sg函数的表 #incl ...

  2. 51nod 1714:B君的游戏(博弈 sg打表)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1714 nim游戏的一个变形,需要打出sg函数的表 #incl ...

  3. S-Nim HDU 1536 博弈 sg函数

    S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...

  4. HDU 5795 A Simple Nim(SG打表找规律)

    SG打表找规律 HDU 5795 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include ...

  5. HDU 3032 (SG打表找规律)

    题意: 有n堆石子,alice先取,每次可以选择拿走一堆石子中的1~x(该堆石子总数) ,也可以选择将这堆石子分成任意的两堆.alice与bob轮流取,取走最后一个石子的人胜利. 思路: 因为数的范围 ...

  6. 博弈SG

    先转一篇看得比较懂的,以后有时间自己再归纳下 转自:http://blog.csdn.net/logic_nut/article/details/4711489 博弈问题若你想仔细学习博弈论,我强烈推 ...

  7. BZOJ-1228 E&D 博弈SG+找啊找啊找规律

    讨厌博弈,找规律找半天还是错的.... 1228: [SDOI2009]E&D Time Limit: 10 Sec Memory Limit: 162 MB Submit: 666 Solv ...

  8. hdu 3032(博弈sg函数)

    题意:与原来基本的尼姆博弈不同的是,可以将一堆石子分成两堆石子也算一步操作,其它的都是一样的. 分析:由于石子的堆数和每一堆石子的数量都很大,所以肯定不能用搜索去求sg函数,现在我们只能通过找规律的办 ...

  9. HDU-4678 Mine 博弈SG函数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4678 题意就不说了,太长了... 这个应该算简单博弈吧.先求联通分量,把空白区域边上的数字个数全部求出 ...

随机推荐

  1. Swift - 给表格添加移动单元格功能(拖动行)

    1,下面的样例是给表格UITableView添加单元格移动功能: (1)给表格添加长按功能,长按后表格进入编辑状态  (2)在编辑状态下,可以看到单元格后面出现拖动按钮  (3)鼠标按住拖动按钮,可以 ...

  2. Servlet的学习之ServletContext(2)

    本篇接上篇<Servlet的学习(五)>,继续从ServletContext对象中的方法进行学习,在这一篇中,我们重点关注的是ServletContext对象中对于在web工程中的资源文件 ...

  3. 解决 Android SDK Manager不能下载旧版本的sdk的问题

    解决无法使用Android SDK  Manager下载SDK开发包的解决办法. 当我们在官网下载google的集成ADT,也就是adt-bundle-linux-x86.zip开发包,进行解压, 打 ...

  4. Oracle死锁、数据库链接问题

    --查询数据库锁表的信息 select do.object_name,t2.username,t2.sid,t2.serial#,t2.logon_time,t2.MACHINE,t2.state,t ...

  5. KNN算法理解

    一.算法概述 1.kNN算法又称为k近邻分类(k-nearest neighbor classification)算法. 最简单平庸的分类器或许是那种死记硬背式的分类器,记住全部的训练数据,对于新的数 ...

  6. Nubia Z5S 基于官方H207/4.4内核的Mokee4.4.4 RC3.2 (2014.7.31修复呼吸灯(能亮依旧不能呼吸))

    特别感谢 yun3195 和 轻描淡写Yhw  帮忙測试 转帖请务必注明本链接地址: http://blog.csdn.net/syhost/article/details/36444259 此ROM ...

  7. 如何配置Git支持大小写敏感和修改文件名中大小写字母呢?(转)

    1. 在新建代码文件时,不注意把文件名应该小小写搞错了2. 文件已经push到远程了3. 在windows下面将文件名字改为全小写 改好后,在Git中没有任何反应,使用git status时,如果遇到 ...

  8. EndNote是一款着名的参考文献管理软件

    EndNote是一款着名的参考文献管理软件,我们可以通过该软件创建个人参考文献库,此外对公司DCC.法务和专 利部门十分的有用,甚至对我们写SOP 也有些帮忙,并且该软件可以在其中加入文本.图像.表格 ...

  9. TComponent明明实现了IDispatch接口,但是却不加上声明,难道是因为FVCLComObject实体对象不存在?

    TComponent明明实现了IDispatch接口,可是它的声明却是: TComponent = class(TPersistent, IInterface, IInterfaceComponent ...

  10. 【IOS工具类】获得设备唯一标识(兼容IOS5,6,7)

    UIDevice+IdentifierAddition.h: #import <Foundation/Foundation.h> @interface UIDevice (Identifi ...