zoukankan      html  css  js  c++  java
  • POJ2348+博弈

    /*
    博弈
    关键态:较大数是较小数的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;
    }
    			
    



  • 相关阅读:
    洛谷月赛 Hello World(升级版)
    codevs1001 舒适的路线
    vijos & codevs 能量项链
    vijos 运输计划
    noip2016普及组题解和心得
    UVa 10891 Game of Sum
    UVa 10635 Prince and Princess
    某模拟题题解 2016.11.17
    贪心入门题
    某模拟题题解 2016.11.16
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3268515.html
Copyright © 2011-2022 走看看