Monday, August 1, 2016

lightoj-1020- A Childhood Game



Suggestion: Don's use or see any source code before you have tried enough.

It's a game theoretical basic problem.If you do not understand it please read first from Shafayater blog>game theory(1).
Source Code in C:

#include<stdio.h>
#include<string.h>
int main()
{
    long long int n,i,m,t;
    char str[10];
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld ",&t);
        scanf("%s",str);

        m=strcmp(str,"Alice");
        if(m==0)
        {
            if(t==1||(t-1)%3==0)
            {
                printf("Case %lld: Bob\n",i);
            }
            else
                 printf("Case %lld: Alice\n",i);
        }else
        {
            if(t%3==0)
            {
                printf("Case %lld: Alice\n",i);
            }
            else
                 printf("Case %lld: Bob\n",i);
        }
    }
    return 0;
}


No comments:

Post a Comment