博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1404
阅读量:4556 次
发布时间:2019-06-08

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

Digital Deletions

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1440    Accepted Submission(s): 517

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:
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:
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
 

 

1 /* 2 分析: 3 1是必败点那么所有被操作成1的数都是必胜点, 4 以此类推由必败点按找游戏的规则反方向推出 5 所有的必胜点。 6 */ 7 #include
8 #include
9 #include
10 #include
11 using namespace std;12 bool sg[1000000];13 14 int get_length(int n)//得到整数n的位数 15 {16 if(n/100000) return 6;17 if(n/10000) return 5;18 if(n/1000) return 4;19 if(n/100) return 3;20 if(n/10) return 2;21 return 1;22 } 23 24 void Deal(int n)25 {26 int m,i,j,base,len,t;27 len=get_length(n);28 for(i=1;i<=len;i++)//对每一位上加上一个数29 {30 m=n;31 base=pow(10,i-1);32 t=(m%(base*10))/base;33 for(j=t;j<9;j++)34 {35 m+=base;36 sg[m]=true;37 }38 }39 m=n;40 base=1;41 for(i=len;i<6;i++)//后面加0开头的数42 {43 m*=10;44 for(j=0;j
>s)63 {64 if(s[0]=='0')//0开头的都是必胜的65 {66 printf("Yes\n");67 continue;68 }69 sum=0;70 for(i=0;i

 

 

 

 

转载于:https://www.cnblogs.com/xiong-/archive/2013/05/21/3089988.html

你可能感兴趣的文章
正则中需要转义的符号
查看>>
Solr局部或指定字段更新之set用法
查看>>
Word Embedding
查看>>
hadoop排序组合键的使用情况
查看>>
Log4cpp介绍及使用
查看>>
linux进程的管道通信
查看>>
Eclipse/myEclipse 代码提示/自动提示/自动完成设置(转)
查看>>
BOM(浏览器对象模型)
查看>>
ride打开后,log和report置灰的解决办法
查看>>
Docker 命令
查看>>
谈谈个人网站的建立(一)——建站历史和技术架构
查看>>
继承中的构造方法
查看>>
【学习】组合数的递推公式
查看>>
对阻塞,非阻塞,同步,异步的深入理解
查看>>
如何卸载lnmp
查看>>
beego: 获取request参数
查看>>
分享.NET ERP项目开发中应用到的重量级工具 选择合适的工具和资源,做项目效率高而且规范程度高...
查看>>
visio studio删除空行
查看>>
Apache编译安装及LAMP架构
查看>>
非root用户下实现SSH免密码登录
查看>>