ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1087. The Time to Take Stones

Please, tell me! How solve Problem 1087... And please tell what's game is right...
Posted by Reshetnikov Eugeny 30 Jan 2002 19:00
In problem said what game is right... What's right game... How must
play first if second gave any stones???
Re: Please, tell me! How solve Problem 1087... And please tell what's game is right...
Posted by tangandctang 4 Apr 2003 15:28
 I am poor in english, so I can't express well.
 I try to use completely search, that is search from 0 to n.
 after getting all state .
 here is my ac code

void computation(int n,int m)
{
    int i,j;
    a[0]=1;
    for(i=1;i<=n;i++)
    {
        bool sign=false;
        for(j=1;j<=m;j++)
            if(i-b[j]>=0&&a[i-b[j]]==2) sign=true;
        if(sign) a[i]=1;
        else a[i]=2;
    }
    printf("%d\n",a[n]);
//    for(i=1;i<=n;i++) printf("%d  ",a[i]);
}