HDOJ1525&POJ2348 Euclid's Game

这是一道找规律的博弈题,我们只要找到谁拥有主动权,而主动权就是当一个数是另外一个数的2倍以上,这时他就可以掌握全局的胜利;

View Code
#include<iostream>
 #include<cstdio>
 #include<cstdlib>
 #include<algorithm>
 #include<cmath>
 #include<queue>
 #include<set>
 #include<map>
 #include<cstring>
 #include<vector>
 #include<string>
 #define LL long long
 using namespace std;
 
 int main(  )
 {
     int n,m;
     while( scanf( "%d %d",&n,&m ),n|m )
     {
        if( n < m ) swap( n , m );
        int cnt = 0;
        while( m!=0&&n/m == 1 )
        {
              cnt++;
              n -= m;
              swap( n , m );        
        }
        if( m != 0  ) 
        {
             if( cnt % 2 == 0 )
             puts( "Stan wins" );
             else puts( "Ollie wins" ) ;
        }
        else if( cnt % 2 == 0 )puts( "Ollie wins" ) ;
             else puts( "Stan wins" );
     }
     //system( "pause" );
     return 0;
 }
 
posted @ 2012-09-21 19:20  wutaoKeen  阅读(235)  评论(0编辑  收藏  举报