zoukankan      html  css  js  c++  java
  • hdu 1525 博弈

    欧几里德问题上的博弈,理解后不难。

    /*
    * hdu1525/win.cpp
    * Created on: 2011-11-11
    * Author : ben
    */
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <set>
    #include <map>
    #include <stack>
    #include <string>
    #include <vector>
    #include <deque>
    #include <list>
    #include <functional>
    #include <numeric>
    #include <cctype>
    using namespace std;
    bool judge(int a, int b) {
    if (a % b == 0) {
    return true;
    }
    int k = a / b;
    if(k <= 1) {
    return !judge(b, a % b);
    }
    return true;
    }

    int main() {
    #ifndef ONLINE_JUDGE
    freopen("data.in", "r", stdin);
    #endif
    int a, b;
    while (scanf("%d%d", &a, &b) == 2) {
    if (a == 0 && b == 0) {
    break;
    }
    if (a < b) {
    a = a ^ b;
    b = a ^ b;
    a = a ^ b;
    }
    if (judge(a, b)) {
    puts("Stan wins");
    } else {
    puts("Ollie wins");
    }
    }
    return 0;
    }



  • 相关阅读:
    Python的logging模块
    Python中的json模块
    Python的re模块
    NoSQL简介
    单例设计模式
    基于配置文件的方式配置AOP
    重用切点表达式
    切面优先级
    返回通知、异常通知、环绕通知
    后置通知
  • 原文地址:https://www.cnblogs.com/moonbay/p/2245879.html
Copyright © 2011-2022 走看看