<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. 初探eXtreme scale

    Note: This document was based on WebSphere Extreme Scale 8.6. It doesn’t supported for lower version ...

  2. 【小白的java成长系列】——javakeyword

    准备出一个系列的内容啦,今天就从keyword開始说起吧~ 类型 keyword 说明 keyword 说明 訪问控制权限 public 公共的.公开的. protected 受保护的.用来修饰属性或 ...

  3. hdu1087Super Jumping! Jumping! Jumping!(最大递增序列和)

    题意:棋牌游戏如今,一种被称为“超级跳!跳!跳!“HDU是非常流行的.也许你是个好孩子,这个游戏知之甚少,所以我介绍给你吧. 可以玩游戏由两个或两个以上的球员 .它由一个棋盘(棋盘)和一些棋子(棋子) ...

  4. bonjour

    首先bonjour并非必须的,可是它的确非常方便,假设没有它我们须要指定ip地址进行局域网的传输,有了它就能够依据服务的详细的名称来选择服务,能够这样来理解bonjour就相当于hostname,我们 ...

  5. c# in depth之泛型的实现

    1.默认值表达式 如果已经明确了要处理的类型,也就知道了它的“默认”值.不知道要引用的类型,就不能直接指定默认值.不能使用null,因为它可能不是一个引用类型,不能使用0,因为它可能不是数值类型.虽然 ...

  6. Boost Thread学习笔记二

    除了thread,boost种:boost::mutexboost::try_mutexboost::timed_mutexboost::recursive_mutexboost::recursive ...

  7. 【Demo 0008】Java基础-抽象类

    本掌学习要点:       1.  了解抽象类的定义及使用场景:       2.  掌握final修饰的类.方法以及变量作用及用法:       3.  掌握abstract 修饰的类及方法作用及用 ...

  8. hdu4847 Wow! Such Doge!(简单题+坑爹的输入)

    转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://acm.hdu.edu.cn/showproblem.php ...

  9. Codeforces Round #218 (Div. 2)

    500pt, 题目链接:http://codeforces.com/problemset/problem/371/A 分析:k-periodic说明每一段长度为k,整个数组被分成这样长度为k的片段,要 ...

  10. find . / -newer oldest_file.txt ! -newer newest_file.txt

    如果希望查找更改时间比某个文件新但比另一个文件旧的所有文件,可以使用-newer选项. 它的一般形式为: $ find . / -newer oldest_file.txt ! -newer newe ...