HDU 1404 (博弈) Digital Deletions
首先如果第一个数字是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的更多相关文章
- Digital Deletions HDU - 1404
Digital deletions is a two-player game. The rule of the game is as following. Begin by writing down ...
- hdu 1404 找sg ***
HDU 1404 Digital Deletions 一串由0~9组成的数字,可以进行两个操作:1.把其中一个数变为比它小的数:2.把其中一个数字0及其右边的所以数字删除. 两人轮流进行操作,最后把 ...
- S-Nim HDU 1536 博弈 sg函数
S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...
- HDU 1404 Digital Deletions (暴力博弈)
题意:给定一个数字串,最长是6,然后有两种操作. 第一种是,把该串中的一个数字换成一个比该数字小的数,比如 5 可以换成 0,1,2,3,4. e.g. 12345 --> 12341 第二 ...
- Hdu 1404 Digital Deletions
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1404 刚开始想采取找规律的方法解题,可以没有发现规律.无奈,只好采用求PN点的方法. 我们假 ...
- hdu 1404/zoj 2725 Digital Deletions 博弈论
暴力打表!! 代码如下: #include<iostream> #include<algorithm> #include<cstdio> #include<c ...
- hdoj 1404 Digital Deletions(博弈论)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1404 一看就是博弈论的题目,但并没有什么思路,看了题解,才明白 就是求六位数的SG函数,暴力一遍,打表 ...
- HDU 5996 博弈
http://acm.hdu.edu.cn/showproblem.php?pid=5996 博弈论待补. 这题变化了一下,因为注意到奇数层的东西(层数从1开始),对手可以模仿地动,那就相当于没动. ...
- HDU 4994 博弈。
F - 6 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
随机推荐
- Javascript获取URL参数值
getQueryString: function (name) { var reg = new RegExp("(^|&)" + name.toLowerCase() + ...
- uva 11374
Problem D: Airport Express In a small city called Iokh, a train service, Airport-Express, takes resi ...
- oc和swift的混编
参考:http://blog.sina.com.cn/s/blog_8d1bc23f0102v5tl.html swift中使用oc类的方法 1.创建一个oc.h文件 2.添加需要倒入的oc类的头文件 ...
- LoaderManager使用详解(二)---了解LoaderManager
了解LoaderManager 这篇文章将介绍LoaderManager类,这是该系列的第二篇文章. 一:Loaders之前世界 二:了解LoaderManager 三:实现Loaders 四:实 ...
- sparksql链接mysql
1.在IDEA上建立一个sparksql_mysql的scala对象. 2.连接mysql的代码如下 import java.sql.{DriverManager, PreparedStatement ...
- 饶有兴致的用javascript做了个贪食蛇游戏
09年写的东西.一直藏在自己的记事本里头,现在开始整理写博客,所以直接搬过来 先上效果图 再添代码: <HTML> <HEAD> <TITLE>贪吃蛇 Snake ...
- Baidu和Google搜索引擎使用技巧(转)
转自:Baidu和Google搜索 http://www.douban.com/note/261208979/ 百度搜索一:基本搜索 二:高级搜索 谷歌搜索一:基本搜索1)可部分匹配也可完全匹 ...
- hdu 4068 SanguoSHA
搜索下就可以了…… 代码如下: #include<iostream> #include<cstring> #include<cstdio> #include< ...
- UML类图、接口、包、关系
一.类图:允许我们去标记静态内容及类之间的关系. 类的基本表示法: 名称 属性(类型,可见性) 方法(参数,返回值) tip: 显示可见性:Options->Show Visibility 显 ...
- 【poj1061-青蛙的约会】拓展欧几里得-不定方程
http://poj.org/problem?id=1061 题意:裸题.注意负数. //poj1061 #include<cstdio> #include<cstdlib> ...