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

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



相关文章:

  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2022-01-30
  • 2022-02-20
  • 2021-10-02
猜你喜欢
  • 2021-05-21
  • 2021-09-12
  • 2021-08-16
  • 2021-09-27
  • 2021-08-25
  • 2022-02-22
  • 2021-09-02
相关资源
相似解决方案