题意:给定一个数字串,最长是6,然后有两种操作。

第一种是,把该串中的一个数字换成一个比该数字小的数,比如 5 可以换成 0,1,2,3,4.   e.g. 12345 --> 12341

第二种是,把数字 0 以及它后面的数都删掉,e.g.  120154 --> 12

析:因为数字最长是 6 位,所以直接把所有的情况都算出来,就好了,这首先 g[1] = 0,然后能够该必败态的,都是必胜态,然后没有到达的点都是必败点,就这样就可以筛选了,还要注意的事从必败态去筛选必胜态的时候,有两种情况,
第一种是把其实的数字进行加法,最高到9。比如 1 筛选的时候, 1 2  3 4 5 6 7 8 9 都要筛选掉,因为这些都能得到 1

第二种不够六位的添加一个0,然后后面, 随便  比如 1  101 102 1012 10123 101234 这样的

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#include <list>
#include <assert.h>
#include <bitset>
#include <numeric>
#define debug() puts("++++")
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a, b, sizeof a)
#define sz size()
#define pu push_up
#define pd push_down
#define cl clear()
#define lowbit(x) -x&x
//#define all 1,n,1
#define FOR(i,x,n) for(int i = (x); i < (n); ++i)
#define freopenr freopen("in.in", "r", stdin)
#define freopenw freopen("out.out", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e17;
const double inf = 1e20;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e6 + 10;
const int maxm = 100 + 2;
const LL mod = 100000000;
const int dr[] = {-1, 1, 0, 0, 1, 1, -1, -1};
const int dc[] = {0, 0, 1, -1, 1, -1, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c) {
return r >= 0 && r < n && c >= 0 && c < m;
} int g[maxn];
char s[10];
int a[10]; void solve(int n){
int len = 0, x = n;
while(x){
a[++len] = x % 10;
x /= 10;
}
for(int i = 1; i <= len; ++i){
int m = 1;
x = i; while(--x) m *= 10;
for(int j = 1; j + a[i] < 10; ++j) g[n+j*m] = 1;
}
x = 6 - len;
int y = 1;
while(x--){
n *= 10;
for(int i = 0; i < y; ++i) g[n+i] = 1;
y *= 10;
}
} int main(){
for(int i = 1; i < 1000000; ++i) if(!g[i]) solve(i);
while(scanf("%s", s) == 1){
if(s[0] == '0'){ puts("Yes"); continue; }
n = atoi(s);
if(g[n]) puts("Yes");
else puts("No");
}
return 0;
}

  

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

  1. Hdu 1404 Digital Deletions

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

  2. hdoj 1404 Digital Deletions(博弈论)

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

  3. hdu 1404 找sg ***

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

  4. Digital Deletions HDU - 1404

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

  5. HDU 1524 树上无环博弈 暴力SG

    一个拓扑结构的图,给定n个棋的位置,每次可以沿边走,不能操作者输. 已经给出了拓扑图了,对于每个棋子找一遍SG最后SG和就行了. /** @Date : 2017-10-13 20:08:45 * @ ...

  6. 取石子游戏 HDU 1527 博弈论 威佐夫博弈

    取石子游戏 HDU 1527 博弈论 威佐夫博弈 题意 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两 ...

  7. HDU 1404 (博弈) Digital Deletions

    首先如果第一个数字是0的话,那么先手必胜. 对于一个已知的先手必败状态,凡是能转移到先手必败的状态一定是必胜状态. 比如1是必败状态,那么2~9可以转移到1,所以是必胜状态. 10,10*,10**, ...

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

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

  9. hdu 5461 Largest Point 暴力

    Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...

随机推荐

  1. 成为JAVA架构师必看书籍推荐

    原创文章 “学习的最好途径就是看书“,这是我自己学习并且小有了一定的积累之后的第一体会.个人认为看书有两点好处: 1.能出版出来的书一定是经过反复的思考.雕琢和审核的,因此从专业性的角度来说,一本好书 ...

  2. go语言template包中模板语法总结

    package main; import ( "html/template" "os" "fmt" ) type Person struct ...

  3. Jfinal适用于条件查询的动态SQL语句生成工具

    条件查询是可能有为空字段,拼接SQL语句时候要屏蔽掉这些字段. package cn.pangpython.utils; import java.util.Iterator; import java. ...

  4. JS打开新窗口,子窗口操作父窗口

    <!--父窗口弹窗代码开始--> <script type="text/javascript"> function OpenWindow() { windo ...

  5. 那些年我们遇到的坑(1)-Description Resource Path Location Type Archive for required library

    在下载JAR包过程中遇到了错误,根据提示找到maven仓库报错的目录,将该目录下的所有文件删除重新下载即可

  6. 在HashTable上下文中,同步指的是什么?

    同步意味着在一个时间点只能有一个线程可以修改hash表,任何线程在执行HashTable的更新操作前都需要获取对象锁,其他线程需要等带锁的释放.

  7. Laravel自定义Api接口全局异常处理

    在做API时,需要对一些异常进行全局处理,比如添加用户执行失败时,需要返回错误信息 // 添加用户 www.bcty365.com $result = User::add($user); if(emp ...

  8. Spring访问数据库(方式上跟HQL类似,每行记录映射一个实体类)

    看了这篇技术博客,觉得收获较大,收藏了:http://sarin.iteye.com/blog/875915

  9. jmeter使用HTTP代理服务器

    浏览器>web服务器 浏览器>HTTP代理服务器>web服务器 jmeter>HTTP代理服务器>web服务器 浏览器>jmeter HTTP服务器>web服 ...

  10. cxf 介绍

    CXF 编辑     目录 1Apache CXF 简介 关于Apache CXF 功能特性 项目目标 2Apache CXF特点 灵活部署 支持多种编程语言 代码生成     1Apache CXF ...