Thursday 16 June 2011

uva 847-A Multiplication Game

//Test this program in the dev c++ compiler otherwise it may not be run
#include <stdio.h>
int main ()
{
    long long n;
//freopen("in.txt","r",stdin);
    while ( scanf ("%lld", &n) != EOF )
    {

        unsigned long p = 1;
        bool stan = true;
        bool ollie = false;

        while ( p < n )
        {

            if(stan)
            {
                p *= 9;
                stan = false;
                ollie = true;
            }

            else
            {
                p *= 2;
                ollie = false;
                stan = true;
            }
        }

        if ( ! stan )
            printf ("Stan wins.\n");
        else
            printf ("Ollie wins.\n");
    }
    //getch();
    return 0;
}

No comments:

Post a Comment