Euclid's Game
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 7 Accepted Submission(s) : 6
25 7
11 7
4 7
4 3
1 3
1 0
an Stan wins.
#include<iostream>
#include<algorithm>
using namespace std; int main()
{
int n,m;
while(cin>>n>>m)
{
if(n==0&&m==0)break;
int cnt=0;
int ans=0;
while(1)
{
if(n<m)swap(n,m);
ans=n/m;
if(ans>=2)break;
cnt++;
n%=m;
if(n==0)
{
cnt++;
break;
}
}
if(cnt%2==1)cout<<"Ollie wins"<<endl;
else cout<<"Stan wins"<<endl;;
}
return 0;
}
Euclid's Game的更多相关文章
- ZOJ1913 Euclid's Game (第一道简单的博弈题)
题目描述: Euclid's Game Time Limit: 2 Seconds Memory Limit: 65536 KB Two players, Stan and Ollie, p ...
- Euclid求最大公约数
Euclid求最大公约数算法 #include <stdio.h> int gcd(int x,int y){ while(x!=y){ if(x>y) x=x-y; else y= ...
- HDU 1525 Euclid's Game 博弈
Euclid's Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- [poj2348]Euclid's Game(博弈论+gcd)
Euclid's Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9033 Accepted: 3695 Des ...
- hdu------(1525)Euclid's Game(博弈决策树)
Euclid's Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1525 Euclid's Game (博弈)
Euclid's Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- 最大公约数与欧几里得(Euclid)算法
---恢复内容开始--- 记a, b的最大公约数为gcd(a, b).显然, gcd(a,b)=gcd(|a|,|b|). 计算最大公约数的Euclid算法基于下面定理: [GCD递归定理]对于任意非 ...
- 求两个数的最大公约数(Euclid算法)
求两个数 p 和 q 的最大公约数(greatest common divisor,gcd),利用性质 如果 p > q, p 和 q 的最大公约数 = q 和 (p % q)的最大公约数. 证 ...
- 最大公约数(gcd):Euclid算法证明
1个常识: 如果 a≥b 并且 b≤a,那么 a=b. 2个前提: 1)只在非负整数范围内讨论两个数 m 和 n 的最大公约数,即 m, n ∈ N. 2)0可以被任何数整除,但是0不能整除任何数,即 ...
- Euclid gcd规则的证明
Euclid 规则:如果x和y都是正整数,而且x>=y,那么gcd(x,y)=gcd(x mod y, y) 假设x和y的gcd为a,那么必然有 x=a*n1 y=a*n2(gcd(n1,n2) ...
随机推荐
- Ubuntu18下sudo apt install xxx出现问题
当执行sudo apt install rpm时失败(apt-get也失败),输出如下报错信息: E: Could not get lock /var/lib/dpkg/lock - open (11 ...
- Linux常用shell命令
1.>>>>>刚安装好的ubuntu需要为root创建密码[解决]passwd root 2.>>>>>安装完ubuntu后需要更新[解决] ...
- python1-集合、函数-(全局变量与局部变量)
集合 # s=set('hello')# print(s)## s=set(['alex','alex','sb'])# print(s) # s={1,2,3,4,5,6} #添加# s.add(' ...
- intptr_t 指针(转)
reference:http://muchong.com/bbs/ 对于64为系统: typedef signed char int8_t; typedef short int int16_t; ty ...
- centos7 eclispe 编译C++遇到的问题总结
最近由于工作的需要,又开始回归之前已经遗忘了的技术.arm嵌入式这个古老的名词. 开始选择了linuxminit,开始的linuxminit17以前还可以,可是用了一下linuxminit19,发现r ...
- Intellij idea配置及安装插件小记一二
1.项目创建慢及控制台乱码解决. -DarchetypeCatalog=internal:项目骨架采用内部,解决Maven项目创建生成慢: -Dfile.encoding=GB2312:控制台用Sys ...
- ie9上传后下载json
1.保持后台控制器返回的数据为字符串格式 2.js:dataType类型保持为html格式 dataType: 'html',//默认就是html类型,不写对火狐有影响 3.将上传后后台返回的字符串转 ...
- FUJI 富士 富仕 串口 N500I N700I 连接
本人丰富的硬件连接经验, 1.出售富士生化设备N500I, N700I 接入,C#代码demo, 可连接机器验证,验证后付款2. 提供宠物行业富士生化设备N500I, N700I型号接入软件技术支持 ...
- MVC部署阿里云躺过的坑
1.端口问题 服务器上的80端口默认是打开的.但要能用必须在阿里云的安全组添加对应的配置. 2.安装IIS 在Windows Service 2012 安装IIS,安装时勾一个总复选框,但有些该分支下 ...
- C16记技术服务支持
1.首页笔记:可以通过点击加号添加笔记的分类,还可以查看最近的10条笔记 2.图形:可以通过查看笔记的比例来分析自己最近的状况 3.快速添加笔记:点击添加笔记能够直接进行笔记 4.时间轴:能够通过文字 ...