HDU 1404 Digital Deletions

Digital Deletions

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


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: 

HDU 1404 Digital Deletions_第1张图片


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
Zhejiang University Local Contest 2006 Preliminary
 

Recommend
Ignatius.L   |   We have carefully selected several similar problems for you:   1517  1536  1079  1524  2147 
 
题目就是给一个数,你可以将每一位变成比他小的数字

289 可以变为 288 209

也可以将0和之后的数字去掉,209可以变成2

要想找到输赢状态可以通过第一个确定的点往后推算,可以每一位加1(不导致产生进位情况下),也可以最后加0,然后在后面各位加,直至长度到达极限

#include
#include
#include
using namespace std;
const int maxn=1e7+10;
int sg[maxn];
char aim[10];

int length(int x)
{
	for(int i=6;i>0;i--)
	{
		int tep=pow(10,i-1);
		if(x/tep)
			return i;
	}
}

void getsg(int x)
{
	int l=length(x);
	int mantissa;
	for(int i=1;i<=l;i++)
	{
		int tep=pow(10,i-1);
		mantissa=x/tep%10;
		int y=x;
		for(int j=mantissa;j<9;j++)
		{
			y+=tep;
			sg[y]=1;
		}
	}
	int y=x,k=1;
	while (l<6)  
    {  
        y=y*10;  
        for (int i=0;i

你可能感兴趣的:(博弈)