可以用搜索的姿势写过。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
long long a,b;
bool Judge(int a,int b)
{
if(a < b) swap(a,b);
if(!b) return false;
int end = a / b;
for(int i = end; i >= 1; --i)
if(!Judge(a - i * b,b))
return true;
return false;
}
int main()
{
long long x,y;
while(scanf("%lld%lld",&x,&y),x + y)
printf("%s\n",Judge(x,y) ? "Stan wins":"Ollie wins");
}#include <cstdio>
#include <cs