首先如果第一个数字是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. PE文件结构

    PE头 typedef struct _IMAGE_NT_HEADERS { DWORD Signature; PE头标识 为固定的ascii码 PE\\ IMAGE_FILE_HEADER File ...

  2. javascript 关于函数的返回值

    在javascript中根据调用方式的不同返回的内容也不同 1.  以函数的形式调用 当以函数的形式调用时, 返回值和函数定义时的 ruturn 有关, return的是数字就number类型, re ...

  3. NET 查找程序集路径(CLR关于Assembly的搜索路径的过程)

    最近在回顾.Net应用程序的执行环境,这里做一个很小的总结,方面以后需要的时候进行查找: CLR必须可以找到正确的Assembly,Net提供了Assembly搜索算法,可以根据.config文件(类 ...

  4. c#实现Socket网络编程

    命名空间: 在网络环境下,我们最感兴趣的两个命名空间是System.Net和 System.Net.Sockets. System.Net命名空间通常与较高程的操作有关,例如download或uplo ...

  5. HDU 1247 Hat’s Words(map,STL,字符处理,string运用)

    题目 用map写超便捷 也可以用字典树来写 我以前是用map的: #include<stdio.h> #include<string.h> #include<algori ...

  6. SGU 102

    For given integer N (1<=N<=104) find amount of positive numbers not greater than N that coprim ...

  7. Spinner学习

    我暂且把Spinner称作下拉选择框吧,先来看一下它的效果: 在layout文件中添加Spinner的代码如下: <Spinner android:id="@+id/planets_s ...

  8. OneApm,NewRelic

    https://newrelic.com/ http://www.csdn.net/article/2013-03-25/2814631-new-relic-mobile-app-real-time- ...

  9. C Primer Plus之存储类、链接和内存管理

    存储时期即生存周期——变量在内存中保留的时间 变量的作用域和链接一起表明程序的哪些部分可以通过变量名来使用该变量. 注意:生存期和作用域是两个不同的概念. 作用域    作用域描述了程序中可以访问一个 ...

  10. 有用的一些web网站

    1.http://www.aseoe.com/api-download/download.html 爱思资源网