Topic Link: http://acm.hdu.edu.cn/showproblem.php?pid=1517
The beginning of a number is 1, two people take turns, each time you can multiply this number by 2-9, who finally get the number is not less than N, who wins.
Train of thought: Continue using the SG function method, here because the array is not sure how large, so the direct use of map storage. SG (1) for 0 will be defeated, or win.
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
# include<iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
ll N;
Map<ll, Int> MP;
int sg (ll x) {
if (x >= N) return 0;
if (Mp.count (x)) return mp[x];
Vector<ll> ha;
for (int i = 2; I <= 9; i++) {
ha.push_back (SG (x*i));
Sort (Ha.begin (), Ha.end ());
int c = 0, cur = 0;
while (cur < ha.size ()) {
if (c!= ha[cur]) {return
mp[x] = c;
}
++cur, ++c;
}
return mp[x] = ha[ha.size () -1]+1;
}
int main () {while
(scanf ("%lld", &n) = = 1) {
mp.clear ();
if (SG (1LL)) printf ("Stan wins.\n");
else printf ("Ollie wins.\n");
}