hdu1404 Digital Deletions
来源:互联网 发布:歼20就是个笑话 知乎 编辑:程序博客网 时间:2024/05/19 15:43
Digital Deletions
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1689 Accepted Submission(s): 605
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由于,数字是很小的,所以可以,先把表打出来,这样,就可以 了!#include <iostream>#include <stdio.h>#include <string.h>using namespace std;#define M 1000000int pri[M],ten[]={1,10,100,1000,10000,100000,1000000};char str[10];int getlen(int 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;}int getsg(int n){ int m,len,i,j,k,low; len=getlen(n); for(i=0;i<len;i++){ m=n;low=(m-m/ten[i+1]*ten[i+1])/ten[i]; for(j=low;j<9;j++){ m+=ten[i];pri[m]=1; } } if(len!=6){ for(i=len,j=1;i<6;i++,j++){ m=n*ten[j]; for( k=0;k<ten[j-1];k++) pri[m+k]=1; } }}int main(){ int i,ans; pri[0]=1; for(int i=1;i<M;i++) if(!pri[i])getsg(i); while(scanf("%s",str)!=EOF){ if(str[0]=='0'){ printf("Yes\n");continue; } for(i=0,ans=0;str[i]!='\0';i++){ ans=ans*10+str[i]-'0'; } if(pri[ans])printf("Yes\n"); else printf("No\n"); } return 0;}
- hdu1404 Digital Deletions------SG
- hdu1404 Digital Deletions
- Hdu1404 Digital Deletions
- hdu1404 Digital Deletions (状压+dfs)
- hdu1404 Digital Deletions SG打表
- Hdu1404 Digital Deletions(暴力SG博弈)
- hdu 1404 Digital Deletions
- Digital Deletions+博弈
- hdu 1404 Digital Deletions
- Hdu 1404 Digital Deletions
- HDU 1404 Digital Deletions
- Digital Deletions - HDU 1404 博弈
- 博弈——Digital Deletions
- SG函数 hdu 1404 Digital Deletions
- sg函数 hdu 1404 Digital Deletions
- hdu 1404 Digital Deletions (SG函数)
- HDU 1404 Digital Deletions [SG]【博弈】
- hdu1404
- 南京网预赛 2013 Install hdu4756_Air Conditioning BY hyoga
- java中的线程同步实现方法一(将方法设置为synchronized)
- sleep和wait区别(线程基本必问的)
- Oracle 11G for Windows下载地址
- 二分查找法
- hdu1404 Digital Deletions
- uva 133 The Dole Queue
- 两个for循环的优缺点
- Jetty Continuation机制
- Good Luck in CET-4 Everybody!
- 闪回数据归档
- 关于Backbone.localstorage.js如何存取
- 百度2014校园招聘笔试题(深圳-软件研发岗)
- SQL Server语句