简单博弈
对于一个状态,要么是必胜,要么必败
对于(a,b) ,a > b来说
若 a % b == 0 直接转化为(b,0),结束
若 a / b > 1 , 设 a = q * b + r , q > 1 , 0 < r < b,则 可以转化为(b + r , b ) 或 ( b , r )
注意(b + r , b ) 也可以转化到 (b , r) ,
考虑状态(b ,r )
若 (b , r ) 是必胜态, 则前者由(a , b) 转化为(b + r , b),那么后者只能转化为(b , r ) ,前者胜,
若(b , r ) 是必败态, 则前者直接将(a , b) 转化为 ( b , r ) 后者必败,前者胜
这题打了好一会表,没发现规律,呜呜呜
/*************************************************************************
> File Name: 1525.cpp
> Author: windhxs
> Mail: 865022197@163.com
> Created Time: 2019年07月15日 星期一 14时45分00秒
************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
LL a,b;
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("data.in","w",stdin);
//freopen("data.out","r",stdout);
while(cin>>a>>b && a + b){
if(b > a) swap(a,b);
int flag = 0 ;
while(1){
if(b > a) swap(a,b);
if(a % b == 0 || a / b > 1) break;
a = a % b;
flag ^= 1;
}
if(!flag) cout<<"Stan wins"<<endl;
else cout<<"Ollie wins"<<endl;
}
return 0;
}