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 711 74 74 31 31 0

an 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 12
15 24
0 0

样例输出
Stan wins
Ollie 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;
}

NUC1445 Euclid's Game【博弈】相关推荐

  1. HDU 1525 - Euclid's Game ( 博弈 )

    题意 Stan和Ollie玩游戏,Stan先手.给出两个数字,可以用大数减去小数的整数倍,要求不能减到小于0.谁先将一个数字减到0,谁获胜. 思路 博弈 假设 a > b 比赛的时候想到了关于a ...

  2. POJ - 2348 Euclid's Game(博弈)

    题目链接:点击查看 题目大意:给出初始的两个数字,每一次操作都要在规则下进行:令较大的数减去任意倍较小的数,必须保证不能出现负数,先减到零者获胜,问谁能获胜 题目分析:这个题目说是博弈我感觉更像是找规 ...

  3. POJ 2348 Euclid's Game(博弈)题解

    题意:有a,b两个数字,两人轮流操作,每次可以选择两个之中较小的数字,然后另一个数字减去选择数字的任意倍数(不能减到负数),直到其中一个为0,不能操作为败 思路:这题用博弈NP思想,必败点和必胜点之间 ...

  4. HDU1525 Euclid's Game 【欧几里得博弈】

    有两个玩家,Stan 和 Ollie, 在玩游戏.初始有两个自然数.Stan是先手,每次把大的数字减去小的数字的任意倍数,但是不能使数字变成负数.然后Ollie进行同样的操作,直到有一个玩家使一个数字 ...

  5. 【 HDU - 1525 】Euclid's Game(较难找规律,玄学博弈,分析必败点必胜点)

    题干: Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, su ...

  6. Bzoj 4147: [AMPPZ2014]Euclidean Nim(博弈)

    4147: [AMPPZ2014]Euclidean Nim Time Limit: 1 Sec Memory Limit: 256 MB Description Euclid和Pythagoras在 ...

  7. 组合博弈游戏 - SG函数和SG定理

    转载来自:http://blog.csdn.net/luomingjun12315/article/details/45555495 在介绍SG函数和SG定理之前我们先介绍介绍必胜点与必败点吧. 必胜 ...

  8. [xiaoyi和你飞]博弈基础 ——[AB]

    问题虫洞: A - Calendar Game 黑洞内窥: 两个人游戏,给出一个初始日期(介于1900.1.1~2001.11.4), 每个人轮流移动一步,移动规则遵循两条: 1,可以转移到当前日期的 ...

  9. Game Theory: 公平博弈

    Notes: The following excerpt is from a book <GAME THEORY>by Thomas && S.Ferguson and a ...

最新文章

  1. Nature news: 未来40年,DNA测序将走向何方?
  2. 第166天:canvas绘制饼状图动画
  3. 映射Mapper.xml文件的几种方式
  4. 华为鸿蒙加快完善,替换安卓!华为鸿蒙OS生态持续扩大:或适配高通平台
  5. Java高级篇(二)——网络通信
  6. 数据结构与算法--将数组排成最小的数
  7. 4月21日会议总结(整理—祁子梁)
  8. Java实现Excel导入数据库,数据库中的数据导入到Excel
  9. python编程制作接金币游戏_一个简单的pygame接金币游戏
  10. IOS scrollView 知识点
  11. phpcms文件夹plugin调用怎么写路径 - 代码篇
  12. 默认网关出现乱码_SpringCloudZuul服务网关
  13. mysql如何给text字段添加索引_MySQL 是如何利用索引的
  14. BAT频繁与移动医疗挂钩 预示行业即将爆发?
  15. 新兴IT企业特斯拉(七)——充电先行
  16. php使用redis实例,php中使用redis队列操作实例代码
  17. PHP中使用imagick生成PSD文件缩略图
  18. Ubuntu键盘鼠标失灵
  19. 【SPEA飞针测试】4085飞针测试机简述
  20. ​“人工智能”初创公司所面临的问题

热门文章

  1. 开源GIS(十四)——openlayers通过geoserver中WFS更改要素
  2. [Serializable]在C#中的作用——实现.NET对象序列化
  3. linux下使用gpio控制代码,zynq linux 下控制gpio的c代码
  4. java ee 程序_第一个 JavaEE 应用程序 - JavaWeb 入门开发教程
  5. 电脑运行内存不足怎么办_win7内存不足怎么办?教你使用虚拟内存来增加win7系统的运行内存...
  6. java jdk1 5手机版,java jdk1.7|java7_绿茶手机网
  7. mach内核和linux对比,海思Hi3511/Hi3512 Linux内核与标准内核差异说明
  8. java一览删除一条数据_可以删除单条数据,不能再返回列表页面,我使用的是Spring MVC...
  9. java 定时器qz xm配置_java_Java的作业调度类库Quartz基本使用指南,一、常用接口: 1、Job接口: - phpStudy...
  10. 三菱fx2n做从站的modbus通讯_三菱FX2N与昆仑通态(MCGS)无线编程口通讯例程