• 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;
    }
  • 相关阅读:
    wpf 3D学习
    vs2010莫名崩溃初探
    Wcf(,service callback client)
    MEF和CompositionContainer学习
    认知Media Queries让浏览器人性化
    移动互联网产品设计的7大误区
    RUP中的迭代模型
    前端工程师的价值体现在哪里?
    做用户研究时,如何挑选合适的用户?
    晒晒 邀请函!感恩节 感谢组织!让我挡上末班车!哈哈!
  • 原文地址:https://www.cnblogs.com/lanjiangzhou/p/3018998.html
Copyright © 2020-2023  润新知