HDU 1404 Digital Deletions (暴力博弈)
题意:给定一个数字串,最长是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 (暴力博弈)的更多相关文章
- Hdu 1404 Digital Deletions
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1404 刚开始想采取找规律的方法解题,可以没有发现规律.无奈,只好采用求PN点的方法. 我们假 ...
- hdoj 1404 Digital Deletions(博弈论)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1404 一看就是博弈论的题目,但并没有什么思路,看了题解,才明白 就是求六位数的SG函数,暴力一遍,打表 ...
- hdu 1404 找sg ***
HDU 1404 Digital Deletions 一串由0~9组成的数字,可以进行两个操作:1.把其中一个数变为比它小的数:2.把其中一个数字0及其右边的所以数字删除. 两人轮流进行操作,最后把 ...
- Digital Deletions HDU - 1404
Digital deletions is a two-player game. The rule of the game is as following. Begin by writing down ...
- HDU 1524 树上无环博弈 暴力SG
一个拓扑结构的图,给定n个棋的位置,每次可以沿边走,不能操作者输. 已经给出了拓扑图了,对于每个棋子找一遍SG最后SG和就行了. /** @Date : 2017-10-13 20:08:45 * @ ...
- 取石子游戏 HDU 1527 博弈论 威佐夫博弈
取石子游戏 HDU 1527 博弈论 威佐夫博弈 题意 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两 ...
- HDU 1404 (博弈) Digital Deletions
首先如果第一个数字是0的话,那么先手必胜. 对于一个已知的先手必败状态,凡是能转移到先手必败的状态一定是必胜状态. 比如1是必败状态,那么2~9可以转移到1,所以是必胜状态. 10,10*,10**, ...
- hdu 1404/zoj 2725 Digital Deletions 博弈论
暴力打表!! 代码如下: #include<iostream> #include<algorithm> #include<cstdio> #include<c ...
- hdu 5461 Largest Point 暴力
Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...
随机推荐
- xcode10 - 打ipa上蒲公英或者fire.im
1.选择空设备 2. 3. 4. 选择需要的 next 5. 6. 7. 8.选择位置 9. 选择ipa包 放到蒲公英 或者fire.im上 就行了
- 2017-2018-2 20165315 实验三《敏捷开发与XP实践》实验报告
2017-2018-2 20165315 实验三<敏捷开发与XP实践>实验报告 一.编码标准 编写代码一个重要的认识是"程序大多时候是给人看的",编程标准使代码更容易阅 ...
- React-router4 第三篇 BasicURL ParametersRedirects (Auth) 谷歌翻译:重定向
依旧是地址 https://reacttraining.com/react-router/web/example/auth-workflow 上来一步走 先导入模块 import React, { P ...
- istio promethus收集不到数据
1.重新apply istio.yaml kubectl apply -f install/kubernetes/istio.yaml kubectl get metrics.config.istio ...
- 虚拟机vmware centos7 扩展磁盘空间
0.思路 创建一个新的逻辑分区,将新的逻辑分区格式化ext3(或其他类型)的文件系统,mount到磁盘空间不够的文件系统,就跟原来的分区/文件系统一样的使用 1.准备 1.1 注意使用VMware自带 ...
- hdu 1394(线段树) 最小逆序数
http://acm.hdu.edu.cn/showproblem.php?pid=1394 给出一列数组,数组里的数都是从0到n-1的,在依次把第一个数放到最后一位的过程中求最小的逆序数 线段树的应 ...
- 网页定时器setTimeout( )
不斷重複執行的 setTimeout( ) setTimeout( ) 預設只是執行一次, 但我們可以使用一個循環方式, 使到一個setTimeout( ) 再啟動自己一次, 就會使到第二個 setT ...
- generic_netlink 用法
参考资料: https://wiki.linuxfoundation.org/networking/generic_netlink_howto generic_netlink 框架 +-------- ...
- MVVM模式理解
MVVM 是Model-View-ViewModel 的缩写,它是一种基于前端开发的架构模式,其核心是提供对View 和 ViewModel 的双向数据绑定,这使得ViewModel 的状态改变可以自 ...
- 提升HTML5的性能体验系列之五 webview启动速度优化及事件顺序解析
webview加载时有5个事件.触发顺序为loading.titleUpdate.rendering.rendered.loaded.webview开始载入页面时触发loading,载入过程中如果&l ...