首先如果第一个数字是0的话,那么先手必胜。

对于一个已知的先手必败状态,凡是能转移到先手必败的状态一定是必胜状态。

比如1是必败状态,那么2~9可以转移到1,所以是必胜状态。

10,10*,10**,10***,10****也都可以删除1后面那个0,转移到1,所以也是必胜状态。

 #include <cstdio>
#include <cstring>
#include <cstdlib> const int maxn = ;
int sg[maxn + ]; void init()
{
char s[], s1[];
for(int i = , j; i <= maxn; i++) if(!sg[i])//先手必败点
{//所有能转移到先手必败的状态都是先手必胜状态
sprintf(s, "%d", i);
int n = strlen(s);
for(j = ; j < n; j++)
{//每一位都加上1
strcpy(s1, s);
while(++s1[j] <= '') sg[atoi(s1)] = ;
}
int m = i, b = ;
for(int j = n; j < ; j++)
{//在后面添0
m *= ;
for(int k = ; k < b; k++) sg[m + k] = ;
b *= ;
}
}
} int main()
{
init();
char s[];
while(scanf("%s", s) == )
{
if(s[] == '') { puts("Yes"); continue; }
int n = , l = strlen(s);
for(int i = ; i < l; i++) n = n * + s[i] - '';
printf("%s\n", sg[n] ? "Yes" : "No");
} return ;
}

代码君

HDU 1404 (博弈) Digital Deletions的更多相关文章

  1. Digital Deletions HDU - 1404

    Digital deletions is a two-player game. The rule of the game is as following. Begin by writing down ...

  2. hdu 1404 找sg ***

    HDU 1404  Digital Deletions 一串由0~9组成的数字,可以进行两个操作:1.把其中一个数变为比它小的数:2.把其中一个数字0及其右边的所以数字删除. 两人轮流进行操作,最后把 ...

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

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

  4. HDU 1404 Digital Deletions (暴力博弈)

    题意:给定一个数字串,最长是6,然后有两种操作. 第一种是,把该串中的一个数字换成一个比该数字小的数,比如 5 可以换成 0,1,2,3,4.   e.g. 12345 --> 12341 第二 ...

  5. Hdu 1404 Digital Deletions

    Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1404 刚开始想采取找规律的方法解题,可以没有发现规律.无奈,只好采用求PN点的方法. 我们假 ...

  6. hdu 1404/zoj 2725 Digital Deletions 博弈论

    暴力打表!! 代码如下: #include<iostream> #include<algorithm> #include<cstdio> #include<c ...

  7. hdoj 1404 Digital Deletions(博弈论)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1404 一看就是博弈论的题目,但并没有什么思路,看了题解,才明白 就是求六位数的SG函数,暴力一遍,打表 ...

  8. HDU 5996 博弈

    http://acm.hdu.edu.cn/showproblem.php?pid=5996 博弈论待补. 这题变化了一下,因为注意到奇数层的东西(层数从1开始),对手可以模仿地动,那就相当于没动. ...

  9. HDU 4994 博弈。

    F - 6 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

随机推荐

  1. asp.net的sessionState节点详解

    web.config关于sessionState节点的配置方案,sessionState有四种模式:off,inProc,StateServer,SqlServer. 1.off模式 从字面上就可以看 ...

  2. http status 汇总

    http status 汇总 常见HTTP状态码 200 OK 301 Moved Permanently 302 Found 304 Not Modified 307 Temporary Redir ...

  3. tomcat 常见错误

    1.启动时加载会话错误 Exception loading sessions from persistent storage 处理方法:删除tomcat对应的项目目录下 work/session.se ...

  4. ZOJ3554 A Miser Boss(dp)

    给你n个工件,然后有A,B,C三个工厂,然后它们加工第i个工件所需要的时间分别为a[i],b[i],c[i],然后现在要你利用三间工厂加工所有的零件,要求是任何时间工厂都不能停工,而且一定要三间同时做 ...

  5. ExtJs之Ext.core.Element

    <!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...

  6. poj 1724(有限制的最短路)

    题目链接:http://poj.org/problem?id=1724 思路: 有限制的最短路,或者说是二维状态吧,在求最短路的时候记录一下花费即可.一开始用SPFA写的,900MS险过啊,然后改成D ...

  7. js小技巧(一)

    事件源对象 event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElement.setCapture();  event.srcE ...

  8. Appium入门示例(python)

    安装Python依赖 pip3.4 install nose pip3.4 install selenium pip3.4 install Appium-Python-Client 运行测试用例and ...

  9. hdu 3853 LOOPS(基础DP求期望)

    题目大意 有一个人被困在一个 R*C(2<=R,C<=1000) 的迷宫中,起初他在 (1,1) 这个点,迷宫的出口是 (R,C).在迷宫的每一个格子中,他能花费 2 个魔法值开启传送通道 ...

  10. hdu 4223

    暴力: Problem : ( Dynamic Programming? ) Judge Status : Accepted RunId : Language : C++ Author : yudun ...