Tuesday, 31 March 2015

UVA 847 A Multiplication Game (HDU 1517, POJ 2505, ZOJ 1893)

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive / spoj), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

//#include<bits/stdc++.h>
#include<iostream>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100010

long long n;

int func(long long cur)
{
    if(cur>=n) return 0;

    int ret=0;
    ret= ret | !func(cur*2);
    ret= ret | !func(cur*9);
    return ret;
}

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);
    int tc, kk=1;
    string s;
    while(cin>>n)
    {
        if(func(1))
            cout<<"Stan wins.\n";
        else cout<<"Ollie wins.\n";

    }
return 0;
}

1 comment:

  1. What is the need of multiplying 2 with cur value. The value which is greater than or equal to cur * 9 is definitely greater than cur * 2. then what is the necessary of this statement.

    ReplyDelete