题意:给一端n块的板,两人玩,每次能涂相邻两块没涂过的板,不能涂的人为输,先手赢输出yes

思路:sg函数打表,练习题

代码:

 #include<queue>
#include<cstring>
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<vector>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define eps 1e-9
typedef long long ll;
const int maxn = + ;
const int seed = ;
const ll MOD = 1e9 + ;
const int INF = 0x3f3f3f3f;
using namespace std;
int sg[], s[];
int main(){
sg[] = , sg[] = , sg[] = ;
for(int i = ; i <= ; i++){
memset(s, , sizeof(s));
for(int j = ; j <= i - ; j++){
int l = j - ;
int r = i - (j + );
s[sg[l] ^ sg[r]] = ;
}
for(int j = ; j < ; j++){
if(!s[j]){
sg[i] = j;
break;
}
}
}
int n;
while(~scanf("%d", &n)){
int ans = ;
int u;
while(n--){
scanf("%d", &u);
ans ^= sg[u];
}
if(ans == ) printf("No\n");
else printf("Yes\n");
}
return ;
}

ZOJ 2083 Win the Game(SG函数)题解的更多相关文章

  1. ZOJ 3057 Beans Game 博弈论 sg函数

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3057 典型的sg函数,数据范围卡得真好啊 代码 #include<c ...

  2. 博弈---ZOJ 2083 Win the Game(染绳子)

    原题:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2083 大意:两个人分别对n条绳子染 每次染m长 最后染不下的输,问先 ...

  3. 题解——牛客网Wannafly挑战赛23 B-游戏 (SG函数)

    前言 比赛的时候没学过SG函数的蒟蒻以为是道结论题,但是不是QwQ 和dummyummy巨佬一起推了快三个小时的规律 最后去问了真正的巨佬__stdcall __stdcall面带微笑的告诉我们,这是 ...

  4. POJ 2425 A Chess Game(有向图SG函数)题解

    题意:给一个有向图,然后个m颗石头放在图上的几个点上,每次只能移动一步,如果不能移动者败 思路:dfs打表sg函数,然后求异或和 代码: #include<queue> #include& ...

  5. LightOJ 1296 Again Stone Game(sg函数)题解

    题意:每次必须拿且只能拿不超过一半的石头,不能拿为败 思路:显然算出每个的sg函数,但是范围1e9显然不能直接打表.所以先打表找规律,发现偶数一直是自己的一半,奇数好像没规律.偶数x的sg函数值是x/ ...

  6. LightOJ 1229 Treblecross(SG函数打表 + 遍历)题解

    题意:给你一串含“.”和“X”的字串,每次一个玩家可以把‘."变成“X”,谁先弄到三个XXX就赢.假如先手必赢,输出所有能必赢的第一步,否则输出0. 思路:显然如果一个X周围两格有X那么肯定 ...

  7. HDU 1848 Fibonacci again and again(SG函数入门)题解

    思路:SG打表 参考:SG函数和SG定理[详解] 代码: #include<queue> #include<cstring> #include<set> #incl ...

  8. ZOJ 3666 博弈 SG函数

    SG函数: 对于任意状态,定义SG(x)=mex(S),其中S是x的后继状态的SG函数值集合,mex(S)表示不再S内的最小非负整数 SG(X)=0当且仅当x为必败态. 解: 构造一个有向无环图(树) ...

  9. HDU 5795 A Simple Nim 打表求SG函数的规律

    A Simple Nim Problem Description   Two players take turns picking candies from n heaps,the player wh ...

随机推荐

  1. 新建虚拟机_XP系统(二)

    准备工作:按照<新建虚拟机_XP系统(一)>中操作步骤创建好虚拟机 1.启动虚拟机进入如下界面.新建分区.选择[6]运行DiskGenius工具 2.选择快速分区.可以自定义 3.新建分区 ...

  2. linux桌面与命令模式切换

    在图形下面按Ctrl+alt+F1(F2\F3\F4)进入命令模式 在命令模式下,按Ctrl+alt+F7回到图形,或登录用户输入startx进入图形!

  3. html中载入自执行getElementById("xx")得到null

    <!DOCTYPE HTML> <html> <head> <title>Scope Chain & Closure Example </ ...

  4. JAVA中只有值传递

    今天,我在一本面试书上看到了关于java的一个参数传递的问题: 写道 java中对象作为参数传递给一个方法,到底是值传递,还是引用传递? 我毫无疑问的回答:“引用传递!”,并且还觉得自己对java的这 ...

  5. python 基础 集合

    集合 集合是一个无序的,不重复的数据组合,它的主要作用如下: 去重,把一个列表变成集合,就自动去重了 关系测试,测试两组数据之前的交集.差集.并集等关系 交集 并集 差集 子集  对称差集 list ...

  6. PHPExcel 基本用法详解

    .header header("Content-Type:application/vnd.ms-excel"); header("Content-Disposition: ...

  7. HDU1203:I NEED A OFFER!(01背包)

    http://acm.hdu.edu.cn/showproblem.php?pid=1203 Problem Description Speakless很早就想出国,现在他已经考完了所有需要的考试,准 ...

  8. [LeetCode] 172. Factorial Trailing Zeroes_Easy tag: Math

    Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explan ...

  9. unity3d-准备工作

    1.软件下载 想进行unity3d游戏开发,首先unity3d官网下载软件:unity3d下载 2.运行游戏界面 3.安装Visual Studio Tools for Unity unity3d自带 ...

  10. Makefile小结

    Makefile最基本的规则:target....:prerequisites..... command 或:target....:prerequisites.....;command target: ...