题目描述

题解:

一道非常简单的$SG$函数应用。

对于一个长度求它的$SG$函数,然后判断是否为$0$即可。

代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = ;
int n,sg[N];
int dfs(int x)
{
if(x<=)return ;
if(~sg[x])return sg[x];
int tmp[N]={};
for(int i=;i<=x;i++)
tmp[dfs(i-)^dfs(x-i-)]=;
for(int i=;;i++)
if(!tmp[i])return sg[x]=i;
}
int main()
{
memset(sg,-,sizeof(sg));
sg[] = ;
while(scanf("%d",&n)>)
{
puts(dfs(n)?"":"");
}
return ;
}

poj3537 Crosses ans Crosses的更多相关文章

  1. 【poj3537】 Crosses ans Crosses

    poj.org/problem?id=3537 (题目链接) 题意 给出一个1*n的棋盘,每次可以选择一个没被标记过的点打标记,若经过某一步操作使得出现3个连续的标记,则最后操作的人获胜.问是否存在先 ...

  2. POJ 3537 Crosses and Crosses

    Crosses and Crosses Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 2237 Accepted: 821 Ca ...

  3. poj 3575 Crosses and Crosses(SG函数)

    Crosses and Crosses Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3063   Accepted: 11 ...

  4. POJ 3537 Crosses and Crosses (NEERC)

                      Crosses and Crosses Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 4 ...

  5. poj3537 Crosses and Crosses 博弈论

    大意: 给定一个\(1 * n\)的棋盘,你和对手轮流在上面画"X" 当出现三个连续的X时,最后一步操作的人胜利 不难发现,在棋盘中画了一个X之后 问题等价于两个一样的子游戏 然后 ...

  6. [poj 3537]Crosses and Crosses(博弈论)

    题目:http://poj.org/problem?id=3537 题意:给你n个格子,两个人依次在n个格子的任意空位置画"X",谁如果画了一个后,3个X连在了一起,那么那个人就获 ...

  7. poj 3537 Crosses and Crosses 博弈论

    思路:每次画X之后都会形成2个子游戏,即i-3和n-i-2. 代码如下: #include<iostream> #include<cstdio> #include<cma ...

  8. 【POJ】【3537】Crosses and Crosses

    博弈论 相当于放了x的位置,左右4格都不能再放x了,谁无处可放就输. n<=2000 直接枚举后继状态,暴力求SG函数即可. 例: 0000000->x..0000 / .x..000 / ...

  9. POJ 3537 Crosses and Crosses(SG/还未想完全通的一道SG)

    题目链接 #include<iostream> #include<cstdio> #include<cstring> using namespace std; ]; ...

随机推荐

  1. hdoj5806【尺取】

    (补题,妈蛋那时候大哥给我说是尺取,我不想打-真是艾斯比了-) 题意: 退役狗 NanoApe 滚回去学文化课啦! 在数学课上,NanoApe 心痒痒又玩起了数列.他在纸上随便写了一个长度为 n 的数 ...

  2. BFS+PRIM

    转载请注明出处:優YoU http://user.qzone.qq.com/289065406/blog/1299324104 在一个y行 x列的迷宫中,有可行走的通路空格' ',不可行走的墙'#', ...

  3. Codeforces731E Funny Game

    dp[i][0]表示从i出发,轮到先手走的最优值. dp[i][1]表示从i出发,轮到后手走的最优值. dp[i][0]=max(dp[j][1]+sum[j]) dp[i][1]=min(dp[j] ...

  4. Apache Kylin 是什么?

    Apache Kylin的官网 http://kylin.apache.org/cn/ - 可扩展超快OLAP引擎:  Kylin是为减少在Hadoop上百亿规模数据查询延迟而设计 - Hadoop ...

  5. jquery html() 和text()的用法

    html()类似JS中的 innerHTML,首先看一段代码: <!DOCTYPE html> <html lang="en"> <head> ...

  6. POJ3417(树上差分)

    会卡vector. ; int n, m, Ans; ], to[maxn * ], tot; int vis[maxn], f[maxn]; int d[maxn], sum[maxn]; vect ...

  7. Mice and Holes CodeForces - 797F

    Mice and Holes CodeForces - 797F 题意:有n只老鼠和m个洞,都在一个数轴上,老鼠坐标为x[1],...,x[n],洞的坐标为p[1],...,p[m],每个洞能容纳的老 ...

  8. 为什么站点使用https加密之后还能看到相关数据

    为什么站点使用了https加密之后,还是能够用firebug之类的软件查看到提交到的信息,并且还是明文的?例如说这样: 这是因为:https(ssl)加密是发生在应用层与传输层之间,所以在传输层看到的 ...

  9. Plugging an Unplugged Pluggable Database

    1.unplug To unplug a PDB, you first close it and then generate an XML manifest file. The XML file co ...

  10. Hash环/一致性Hash原理

    当前,Memcached.Redis这类分布式kv缓存已经非常普遍.从本篇开始,本系列将分析分布式缓存相关的原理.使用策略和最佳实践. 我们知道Memcached的分布式其实是一种“伪分布式”,也就是 ...