hdu 1404 找sg ***
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 ***的更多相关文章
- S-Nim HDU 1536 博弈 sg函数
S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...
- HDU 3032 (SG打表找规律)
题意: 有n堆石子,alice先取,每次可以选择拿走一堆石子中的1~x(该堆石子总数) ,也可以选择将这堆石子分成任意的两堆.alice与bob轮流取,取走最后一个石子的人胜利. 思路: 因为数的范围 ...
- Hdu 1404 Digital Deletions
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1404 刚开始想采取找规律的方法解题,可以没有发现规律.无奈,只好采用求PN点的方法. 我们假 ...
- HDU 4678 Mine SG博弈
http://acm.hdu.edu.cn/showproblem.php?pid=4678 自己太蠢...没学SG...还是浩神指点我SG精髓以后才A的这题...(第一题SG 这里子游戏之间没有影响 ...
- hdu 1848 简单SG函数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1848 Problem Description 任何一个大学生对菲波那契数列(Fibonacci num ...
- hdu 5051 找规律?+大trick
http://acm.hdu.edu.cn/showproblem.php?pid=5051 打表找规律 据说是http://zh.wikipedia.org/wiki/%E6%9C%AC%E7%A6 ...
- HDU 2082 找单词 (普通母函数)
题目链接 Problem Description 假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26.那么,对于 ...
- hdu 5247 找连续数(思维)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5247 找连续数 Time Limit: 2000/1000 MS (Java/Others) M ...
- HDU 2082 找单词 (普通型 数量有限 母函数)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2082 找单词 Time Limit: 1000/1000 MS (Java/Others) Me ...
随机推荐
- devstack两次以上重装提高成功率的方法
1) /opt/stack/requirements/ git reset --hard 2) rm -rf /usr/local/lib/python2.7/dist-packages/*
- HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth之完全详解
HTML:scrollLeft,scrollWidth,clientWidth,offsetWidth到底指的哪到哪的距离之完全详解 scrollHeight: 获取对象的滚动高度. scrollLe ...
- Metronic 与 VS2013/2015 合作开发
Metronic 与 VS2013/2015 合作开发 去年购买了一个:METRONIC (http://www.keenthemes.com/) ,最近下了最新的版本:V3.7 ,解压缩后,目录 ...
- 【leetcode】Valid Number
Valid Number Validate if a given string is numeric. Some examples:"0" => true" 0.1 ...
- windows下安装Apache 64bit
文件下载:http://pan.baidu.com/s/1c0oDjFE 一.Apache的安装 http://www.blogjava.net/greatyuqing/archive/2013/02 ...
- oracle11g 连接问题
一.The Network Adapter could not establish the connection 状态: 失败 -测试失败: IO 错误: The Network Adapter c ...
- Unity3d 制作动态Mesh且可以随地面凹凸起伏
适用情景:主角带着光环,光环用一张贴图,要贴在地面上,并且随地面凹凸起伏 //代码 using UnityEngine; using System.Collections; [RequireCompo ...
- delphi控件属性大全-详解-简介
http://blog.csdn.net/u011096030/article/details/18716713 button 组件: CAPTION 属性 :用于在按钮上显示文本内容 Cancel ...
- java sleep() 、yield()
1.sleep() 使当前线程(即调用该方法的线程)暂停执行一段时间,让其他线程有机会继续执行,但它并不释放对象锁.也就是说如果有synchronized同步快,其他线程仍然不能访问共享数据.注意该方 ...
- HTML~From
表单用于向服务器传输数据. http://www.w3school.com.cn/tags/tag_form.asp 文本域(Text fields) 本例演示如何在HTML页面创建文本域.用户可以在 ...