NUC1445 Euclid's Game【博弈】
来源:互联网 发布:c语言精品课程网站 编辑:程序博客网 时间:2024/05/15 23:54
Euclid's Game
时间限制: 1000ms 内存限制: 65535KB
问题描述
Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtracts any positive multiple of the lesser of the two numbers from the greater of the two numbers, provided that the resulting number must be nonnegative. Then Ollie, the second player, does the same with the two resulting numbers, then Stan, etc., alternately, until one player is able to subtract a multiple of the lesser number from the greater to reach 0, and thereby wins. For example, the players may start with (25,7):
25 7 11 7 4 7 4 3 1 3 1 0an Stan wins.
输入描述
The input consists of a number of lines. Each line contains two positive integers giving the starting two numbers of the game. Stan always starts.
输出描述
For each line of input, output one line saying either Stan wins or Ollie wins assuming that both of them play perfectly. The last line of input contains two zeroes and should not be processed.
样例输入
34 1215 240 0
样例输出
Stan winsOllie wins
来源
Waterloo local 2002.09.28
问题分析:(略)
这个问题和《POJ2348 UVa10368 HDU1525 Euclid's Game【博弈】》是同一个问题,代码拿过来用就AC了。
程序说明:参见参考链接。
参考链接:POJ2348 UVa10368 HDU1525 Euclid's Game【博弈】
题记:程序做多了,不定哪天遇见似曾相识的。AC的C++程序如下:
/* POJ2348 UVa10368 HDU1525 Euclid's Game */ #include <iostream> using namespace std; int main() { int a, b; while(cin >> a >> b && (a || b)) { bool Stanwins = true; if(a < b) swap(a, b); while(b) { if(a % b == 0 || a / b > 1) break; a = a - b; swap(a, b); Stanwins = !Stanwins; } if(Stanwins) cout << "Stan wins" << endl; else cout << "Ollie wins" << endl; } return 0; }
阅读全文
0 0
- NUC1445 Euclid's Game【博弈】
- Euclid's Game---博弈
- hdu1525 Euclid's Game 博弈
- pku 2348 Euclid's Game(博弈)
- POj-2348-Euclid's Game-博弈
- HDU 1525 Euclid's Game (博弈)
- HDOJ 1525 Euclid's Game 博弈
- pku 2348 Euclid's Game(简单博弈)
- hdu 1525 Euclid's Game 博弈
- [简单博弈] hdu 1525 Euclid's Game
- UVA 10368 - Euclid's Game(数论+博弈)
- uva 10368 - Euclid's Game(博弈)
- hdu1525 Euclid's Game , 基础博弈
- POJ 2348 Euclid's Game(博弈)
- hdu 1525 Euclid's Game 博弈
- HDU 1525 Euclid's Game 博弈
- HDU 1525 Euclid's Game (博弈)
- HDU1525 Euclid's Game(博弈)
- 辗转相除法求最大公约数和最小公倍数
- 深度学习调参策略(二)
- Spring AOP的日志记录
- JAVAC配置
- P1424 小鱼的航程(改进版)
- NUC1445 Euclid's Game【博弈】
- webpack安装使用
- Java中的集合、枚举、泛型【上】
- jQuery Treeview 简介
- JS面向对象编程--封装
- 树回归
- 牛人们的面试心得与总结
- MNIST数据可视化
- Spring AOP中自我调用的问题