Digital Deletions - HDU 1404 博弈
来源:互联网 发布:淘宝孕妇套装 编辑:程序博客网 时间:2024/06/07 15:52
Digital Deletions
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2191 Accepted Submission(s): 773
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.
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.
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
000120
Sample Output
YesYesNoNo
题意:每次操作可以将一个0及其以后的数字去掉,或将一个1-9的数字降低其大小。移走最后一个数字的人获胜,问先手胜负。
思路:暴力打表即可。
AC代码如下:
#include<cstdio>#include<cstring>using namespace std;int len;bool win[1000000];char s[10];bool solve(int num){ int i,j,k,k2=num,p=1; while(k2) { k=num/p%10; if(k==0) { if(!win[num/p/10]) return true; } else { for(i=1;i<=k;i++) { if(!win[num-i*p] && !(i==k && k2/10==0)) return true; } } k2/=10; p*=10; } return false;}int main(){ int i,j,k; win[0]=1; for(i=1;i<1000000;i++) if(solve(i)) win[i]=1; while(~scanf("%s",s+1)) { if(s[1]=='0') { printf("Yes\n"); continue; } len=strlen(s+1); k=0; for(i=1;i<=len;i++) k=k*10+s[i]-'0'; if(win[k]) printf("Yes\n"); else printf("No\n"); }}
0 0
- Digital Deletions - HDU 1404 博弈
- HDU 1404 Digital Deletions [SG]【博弈】
- hdu 1404 Digital Deletions
- hdu 1404 Digital Deletions
- Hdu 1404 Digital Deletions
- HDU 1404 Digital Deletions
- Digital Deletions+博弈
- SG函数 hdu 1404 Digital Deletions
- sg函数 hdu 1404 Digital Deletions
- hdu 1404 Digital Deletions (SG函数)
- 博弈——Digital Deletions
- Hdu1404 Digital Deletions(暴力SG博弈)
- hdu1404 Digital Deletions------SG
- hdu1404 Digital Deletions
- Hdu1404 Digital Deletions
- hdu1404 Digital Deletions (状压+dfs)
- hdu1404 Digital Deletions SG打表
- hdu 1404(博弈)
- 安卓开发——AndroidManifest.xml配置详解一
- android fragment 的使用
- Java的文件名必须和公共类名相同
- Android笔记---错误笔记
- 第1章Java开发入门
- Digital Deletions - HDU 1404 博弈
- Unity5.1 新的网络引擎UNET(七) UNET 单人游戏转换为多人
- 黑马day17 ajax&实现用户名自动刷新
- Memcached Java Client API详解
- C++ : 引用的实质理解 !!!!
- 【Android游戏开发之六】无法在SurfaceView中添加组件的替代方法
- 栈的压入、弹出序列
- 给出两个年月日,计算出天数差。
- 牛顿法和拟牛顿法