Hdu 1404 Digital Deletions

Digital Deletions

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


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

SG函数

#include<cstdio>
#include<cstring>

int vis[110];
int SG[11][11][11][11][11][11];

void fun()
{
    int i,j;
    int cnt[10];

    SG[0][0][0][0][0][0]=0;
    for(cnt[1]=1;cnt[1]<=10;cnt[1]++)
    {
        for(cnt[2]=0;cnt[2]<=10;cnt[2]++)
        {
            for(cnt[3]=0;cnt[3]<=10;cnt[3]++)
            {
                if(cnt[2]==0 && cnt[3]!=0)
                    break;
                for(cnt[4]=0;cnt[4]<=10;cnt[4]++)
                {
                    if(cnt[3]==0 && cnt[4]!=0)
                        break;
                    for(cnt[5]=0;cnt[5]<=10;cnt[5]++)
                    {
                        if(cnt[4]==0 && cnt[5]!=0)
                            break;
                        for(cnt[6]=0;cnt[6]<=10;cnt[6]++)
                        {
                            if(cnt[5]==0 && cnt[6]!=0)
                                break;
                            memset(vis,0,sizeof(vis));
                            if(cnt[1]>1)
                            {
                                for(j=1;j<cnt[1];j++)
                                    vis[SG[j][cnt[2]][cnt[3]][cnt[4]][cnt[5]][cnt[6]]]=1;
                            }
                             if(cnt[2]>1)
                            {
                                for(j=1;j<cnt[2];j++)
                                    vis[SG[cnt[1]][j][cnt[3]][cnt[4]][cnt[5]][cnt[6]]]=1;
                            }
                             if(cnt[3]>1)
                            {
                                for(j=1;j<cnt[3];j++)
                                    vis[SG[cnt[1]][cnt[2]][j][cnt[4]][cnt[5]][cnt[6]]]=1;
                            }
                            if(cnt[4]>1)
                            {
                                for(j=1;j<cnt[4];j++)
                                    vis[SG[cnt[1]][cnt[2]][cnt[3]][j][cnt[5]][cnt[6]]]=1;
                            }
                            if(cnt[5]>1)
                            {
                                for(j=1;j<cnt[5];j++)
                                    vis[SG[cnt[1]][cnt[2]][cnt[3]][cnt[4]][j][cnt[6]]]=1;
                            }
                            if(cnt[6]>1)
                            {
                                for(j=1;j<cnt[6];j++)
                                    vis[SG[cnt[1]][cnt[2]][cnt[3]][cnt[4]][cnt[5]][j]]=1;
                            }
                           if(cnt[1]==1)
                                vis[SG[0][0][0][0][0][0]]=1;
                            if(cnt[2]==1)
                                vis[SG[cnt[1]][0][0][0][0][0]]=1;
                            if(cnt[3]==1)
                                vis[SG[cnt[1]][cnt[2]][0][0][0][0]]=1;
                            if(cnt[4]==1)
                                vis[SG[cnt[1]][cnt[2]][cnt[3]][0][0][0]]=1;
                             if(cnt[5]==1)
                                vis[SG[cnt[1]][cnt[2]][cnt[3]][cnt[4]][0][0]]=1;
                            if(cnt[6]==1)
                                vis[SG[cnt[1]][cnt[2]][cnt[3]][cnt[4]][cnt[5]][0]]=1;
                            for(i=0;i<100;i++)
                            {
                                if(vis[i]==0)
                                {
                                    SG[cnt[1]][cnt[2]][cnt[3]][cnt[4]][cnt[5]][cnt[6]]=i;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}


int main()
{
    char ch[10];
    int tmp[10];
    int i;
    fun();
    while(scanf("%s",ch)==1)
    {
        int L=strlen(ch);
        for(i=0;i<L;i++)
        {
            tmp[i]=ch[i]-'0'+1;
        }
        while(i<6)
        {
            tmp[i++]=0;
        }
        if(SG[tmp[0]][tmp[1]][tmp[2]][tmp[3]][tmp[4]][tmp[5]]==0)
            printf("No\n");
        else
            printf("Yes\n");
    }

    return 0;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值