思路:在做gcd时记录每种状态的必输必赢态
代码:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
#define LL long long
int gcd(int a,int b)
{
if(b==0)
return 0;
else
{
if(a/b==1)
return (gcd(b,a%b)+1)%2;
else
return 1;
}
}
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF&&(n||m))
{
int ma=max(n,m),mi=min(n,m);
int ans=gcd(ma,mi);
if(ans==1)
puts("Stan wins");
else
puts("Ollie wins");
}
}