/*
博弈
关键态:较大数是较小数的2倍以上。
*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<math.h>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const int maxn = 1005;
const int inf = 0x7fffffff;
const double pi=acos(-1.0);
const double eps = 1e-8;
int Record[ maxn ];
int main(){
int n,m;
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
while( scanf("%d%d",&n,&m)==2,n+m ){
if( n<m ) swap( n,m );
if( n%m==0 ){
puts("Stan wins");
continue;
}
int cnt = 0;
int r;
while( 1 ){
r = n%m;
Record[ cnt++ ] = n/m;
n = max( m,r );
m = min( m,r );
if( r==0 ) break;
}
int f;
for( f=0;f<cnt;f++ ){
if( Record[f]>1 ){
break;
}
}
if( f==cnt ){
if( f%2==1 ) puts("Stan wins");
else puts("Ollie wins");//没有达到关键态
}
else{
if( f%2==1 ) puts("Ollie wins");
else puts("Stan wins");
//表示达到了关键态,即较大数是较小数的2倍以上。
}
}
return 0;
}
POJ2348+博弈
最新推荐文章于 2021-01-24 21:53:31 发布