hdu 1525找规律博弈

题意:给你两个数,每次可以拿大的那个数减去小的那个数的正整数倍,只要减去后得到的数是正的或者0就行,谁先得到其中一个数是0,谁就胜出。
我们会发现,假设a>b,如果a/b>=2,那么后面就会出现a/b种路线,当a/b=1的时候只有一种路线,所以谁到了a/b>=2这个局面就有必胜策略,此外,当a%b==0的时候,就直接跳出来了,也是必胜点。

View Code
// I'm lanjiangzhou
//C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
//C++
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#include <stack>
#include <string>
#include <list>
#include <queue>
#include <map>
#include <vector>
#include <deque>
#include <set>
using namespace std;

//*************************OUTPUT*************************
#ifdef WIN32
#define INT64 "%I64d"
#define UINT64 "%I64u"
#else
#define INT64 "%lld"
#define UINT64 "%llu"
#endif

//**************************CONSTANT***********************
#define INF 0x3f3f3f3f

// aply for the memory of the stack
//#pragma comment (linker, "/STACK:1024000000,1024000000")
//end


int main(){
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF){
        if(n==0&&m==0) break;
        bool stan=true;
        while(1){
            if(n<m){
                int t=n;
                n=m;
                m=t;
            }
            if(n==0||m==0||(n/m>=2)||(n%m==0)) break;
            n=n%m;
            stan=!stan;
        }
        if(stan) printf("Stan wins\n");
        else printf("Ollie wins\n");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/lanjiangzhou/p/3018998.html