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;
}



原文地址:https://www.cnblogs.com/moonbay/p/2245879.html