博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ACM HDU 1404 Digital Deletions(博弈)
阅读量:7057 次
发布时间:2019-06-28

本文共 2076 字,大约阅读时间需要 6 分钟。

题目链接:

 

本文作者:kuangbin

 

转载请注明出处。 

 

题目:

Digital Deletions

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 785    Accepted Submission(s): 287

Problem Description
Digital deletions is a two-player game. The rule of the game is as following.
Begin by writing down a string of digits (numbers) that's as long or as short as you like. The digits can be 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and appear in any combinations that you like. You don't have to use them all. Here is an example:
1404-1.gif
On a turn a player may either:
Change any one of the digits to a value less than the number that it is. (No negative numbers are allowed.) For example, you could change a 5 into a 4, 3, 2, 1, or 0.
Erase a zero and all the digits to the right of it.
The player who removes the last digit wins.
The game that begins with the string of numbers above could proceed like this:
1404-2.gif
Now, given a initial string, try to determine can the first player win if the two players play optimally both.
 

 

Input
The input consists of several test cases. For each case, there is a string in one line.
The length of string will be in the range of [1,6]. The string contains only digit characters.
Proceed to the end of file.
 

 

Output
Output Yes in a line if the first player can win the game, otherwise output No.
 

 

Sample Input
0 00 1 20
 

 

Sample Output
Yes Yes No No
 

 

Author
ZHENG, Jianqiang
 

 

Source
 

 

Recommend
Ignatius.L
 
 
             HDU 1404  Digital Deletions

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

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

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

程序:

/* HDU 1404 */ #include
#include
#include
#include
using namespace std; const int MAXN=1000000; int sg[MAXN]; int get_length(int n)//得到整数n的位数 {
if(n/100000) return 6; if(n/10000) return 5; if(n/1000) return 4; if(n/100) return 3; if(n/10) return 2; return 1; } void _extend(int n)//sg[n]=0;表示n为后者必胜 //那么所以可以一步变成n的都是前者必胜 {
int len=get_length(n); int i; for(i=len;i>=1;i--)//每一个位上加上一个数 {
int m=n; int base=1; for(int j=1;j

你可能感兴趣的文章
DDL和DML的定义和区别
查看>>
Spring+Quartz实现定时任务的配置方法
查看>>
rsyslog日志格式介绍
查看>>
SAP 设置或取消仓库不参与MRP运算
查看>>
python 基础(三)
查看>>
BeanShell脚本接口之this引用接口类型
查看>>
mysql的复制集群,及读写分离
查看>>
易付宝 大苏宁战略的重要武器
查看>>
IPSec ***原理与配置
查看>>
让群辉支持DTS音轨
查看>>
移动端dropload插件的使用
查看>>
剑指OFFER(java)-二维数组中的查找
查看>>
华云数据与锐捷网络达成战略合作 聚焦行业云
查看>>
RHEL5.2利用lvm增加linux根分区的容量
查看>>
MDT 2013排错Provider:SQL Network Interfaces,error:26
查看>>
桌面支持--不能显示中文字体,系统已调成中文 而且不能打字
查看>>
古城钟楼微博:葡萄城程序员演练技术的产物
查看>>
最常用的四种数据分析方法
查看>>
Mesos安装部署笔记
查看>>
epoll的作用和原理介绍
查看>>