HDU 1404  Digital Deletions

一串由0~9组成的数字,可以进行两个操作:1、把其中一个数变为比它小的数;2、把其中一个数字0及其右边的所以数字删除。

两人轮流进行操作,最后把所以数字删除的人获胜,问前者胜还是后者胜。

字符串长度为1-6,前者胜输出Yes,否则输出No.

 #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
const int INF=0x3f3f3f3f;
const double eps=1e-;
typedef long long ll;
#define cl(a) memset(a,0,sizeof(a))
#define ts printf("*****\n");
const int MAXN=;
int m,tt;
bool sg[MAXN];
void fun(int n)
{
int i,j,k;
char ss[];
sprintf(ss,"%d",n);
int len=strlen(ss);
for(i=;i<len;i++) //在每位上添加数字
{
int temp=n;
char tss[];
strcpy(tss,ss);
while(tss[i]<'')
{
tss[i]+=;
sscanf(tss,"%d",&temp);
sg[temp]=;
}
}
if(len!=)
{
int temp=n;
int base=;
for(i=len;i<;i++)
{
temp*=;
for(j=;j<base;j++)
{
sg[temp+j]=;
}
base*=;
}
}
}
void init()
{
sg[]=;
for(int i=;i<MAXN;i++)
{
if(!sg[i])
{
fun(i);
}
}
}
int main()
{
int i,j,k,ca=;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
cl(sg);
init();
char s[];
while(scanf("%s",s)!=EOF)
{
int n=;
if(s[]=='')
{
printf("Yes\n");
continue;
}
int len=strlen(s);
for(i=;i<len;i++)
{
n*=;
n+=s[i]-'';
}
if(sg[n]) printf("Yes\n");
else printf("No\n");
}
}

hdu 1404 找sg ***的更多相关文章

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

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

  2. HDU 3032 (SG打表找规律)

    题意: 有n堆石子,alice先取,每次可以选择拿走一堆石子中的1~x(该堆石子总数) ,也可以选择将这堆石子分成任意的两堆.alice与bob轮流取,取走最后一个石子的人胜利. 思路: 因为数的范围 ...

  3. Hdu 1404 Digital Deletions

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

  4. HDU 4678 Mine SG博弈

    http://acm.hdu.edu.cn/showproblem.php?pid=4678 自己太蠢...没学SG...还是浩神指点我SG精髓以后才A的这题...(第一题SG 这里子游戏之间没有影响 ...

  5. hdu 1848 简单SG函数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1848 Problem Description 任何一个大学生对菲波那契数列(Fibonacci num ...

  6. hdu 5051 找规律?+大trick

    http://acm.hdu.edu.cn/showproblem.php?pid=5051 打表找规律 据说是http://zh.wikipedia.org/wiki/%E6%9C%AC%E7%A6 ...

  7. HDU 2082 找单词 (普通母函数)

    题目链接 Problem Description 假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于 ...

  8. hdu 5247 找连续数(思维)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5247 找连续数 Time Limit: 2000/1000 MS (Java/Others)    M ...

  9. HDU 2082 找单词 (普通型 数量有限 母函数)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2082 找单词 Time Limit: 1000/1000 MS (Java/Others)    Me ...

随机推荐

  1. Lua简易入门教程

    环境:lua for windows (lfW)主页:http://luaforwindows.luaforge.net/https://code.google.com/p/luaforwindows ...

  2. Isomorphic Strings

    Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara ...

  3. STL---list(列表)

    Lists将元素按顺序储存在链表中. 与 向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比较慢. list的类模板声明为 template<class T, class A ...

  4. 4个http常用的content type

    转的: http://www.aikaiyuan.com/6324.html HTTP/1.1 协议规定的 HTTP 请求方法有 OPTIONS.GET.HEAD.POST.PUT.DELETE.TR ...

  5. linux的提示信息--/etc/motd和/etc/issue

    /etc/motd 即 message of the day 每次用户登录时,这个文件的内容都会显示在用户的终端上.如果shell支持中文,还可以使用中文,这样看起来更加舒服. 成功登录后,自动输出. ...

  6. 9.nodejs权威指南--Socket.IO

    1. Socket.IO 1.1 服务器 var http = require('http'); var sio = require('socket.io'); var fs = require('f ...

  7. jquery若干问题

    1.获取服务器端的控件 $("#<%=photopath.ClientID%>").uploadPreview({ Img: "ImgPr", Wi ...

  8. nyoj305_表达式求值

    表达式求值 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 Dr.Kong设计的机器人卡多掌握了加减法运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min ...

  9. JS 基础 入门

    JS做弹窗效果 //单行注释/*多行注释*/// 网页 标签语言    js语言是脚本语言/* 数据类型: 容器 1.整型  (int)  2.小数类型: float: 单精度的小数: double: ...

  10. SQL Server 子查询

    这些主要是老师上课讲的一些知识点,自己做了一些整理放在这里~~~ 子查询可以是标量的.多值的或是表值的. 在期待单个值的地方可以使用标量子查询.例如,以下查询返回具有最大员工编号的员工信息: SELE ...