[poj2348]Euclid's Game(博弈论+gcd)
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 9033 | Accepted: 3695 |
Description
- 25 7
11 7
4 7
4 3
1 3
1 0
an Stan wins.
Input
Output
Sample Input
- 34 12
- 15 24
- 0 0
Sample Output
- Stan wins
- Ollie wins
Source
- #include<cstdio>
- #include<cstdlib>
- #include<cstring>
- #include<algorithm>
- #define LL long long
- int main(){
- int tmp,n,m,pl;
- while(scanf("%d %d",&n,&m)!=EOF&&(n&&m)){
- pl=;
- while(n&&m){
- if(m<n){tmp=m;m=n;n=tmp;}
- if((n<<)>&&m>=(n<<))break;
- m=m%n;
- if(!m)break;
- pl^=;
- }
- if(!pl)puts("Stan wins");
- else puts("Ollie wins");
- }
- return ;
- }
[poj2348]Euclid's Game(博弈论+gcd)的更多相关文章
- 【博弈论】poj2348 Euclid's Game
假设当前b>a. 一.b%a==0 必胜 二.b<2*a,当前我们没有选择的余地,若下一步是必胜(最终能到情况一),则当前必败:反之,当前必胜. 三.b>2*a,假设x是使得b-ax ...
- POJ 2348 Euclid's Game 博弈论
http://poj.org/problem?id=2348 顺便说,必应翻译真的好用,比谷歌翻译好用100倍. 很难判断这道题的具体博弈类型. 有两种写法,一种是找规律,一种是推理得到关系后循环(或 ...
- hdu 1525 Euclid's Game 博弈论
思路:两个数a和b,总会出现的一个局面是b,a%b,这是必然的,如果a>=b&&a<2*b,那么只有一种情况,直接到b,a%b.否则有多种情况. 对于a/b==1这种局面, ...
- [POJ2348]Euclid's Game
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8313 Accepted: 3374 Description Two p ...
- 博弈论BOSS
基础博弈的小结:http://blog.csdn.net/acm_cxlove/article/details/7854530 经典翻硬币游戏小结:http://blog.csdn.net/acm_c ...
- Design and Analysis of Algorithms_Introduction
I collect and make up this pseudocode from the book: <<Introduction to the Design and Analysis ...
- C#读取图片Exif信息
Exif是可交换图像文件的缩写,是专门为数码相机的照片设定的,可以记录数码照片的属性和拍摄数据 ////调用 //string strFile="fffff.jpg";//文件名 ...
- C++基础学习教程(五)
这一讲我们集中解说类和他的一些特性.首先我们从自己定义一个有理数类来開始. 在C语言中有一个keyword: struct ,用来创建一个结构体类型.可是在C++中这个关键的含义就不只如此了,以下我们 ...
- poj分类解题报告索引
图论 图论解题报告索引 DFS poj1321 - 棋盘问题 poj1416 - Shredding Company poj2676 - Sudoku poj2488 - A Knight's Jou ...
随机推荐
- mapreduce性能提升2
mapreduce性能提升2mapreduce性能提升2mapreduce性能提升2
- Leetcode: Encode String with Shortest Length && G面经
Given a non-empty string, encode the string such that its encoded length is the shortest. The encodi ...
- 搭建git for windows服务器
文档出处 :http://blog.csdn.net/code_style/article/details/38764203 http://blog.csdn.net/aaron_luchen/art ...
- [原创]Android Lollipop (5.0) 原生代码 Settings 首页加载逻辑分析
主入口为com.android.settings.Settings. 这只是一个wrapper的类, 它继承于 SettingsActivity类,并且声明了一堆公有的继承于SettingsActiv ...
- iOS简单动画
知识架构 CALayer 图层类 CABasicAnimation 基础动画 CAKeyFrameAnimation 帧动画 CATransition 转场动画 CAAnimationGroup 动画 ...
- Apache部署django项目
在此之前,我们一直使用django的manage.py 的runserver 命令来运行django应用,但这只是我们的开发环境,当项目真正部署上线的时候这做就不可行了,必须将我们的项目部署到特定的w ...
- Upnp资料整理
系统,软件和路由器都要打开upnp功能. windows7下,分别启动 function discovery resources publication; Upnp device host; SSDp ...
- Connect to Database Using Custom params链接数据库配置参数说明
使用RF的关键字Connect to Database Using Custom params链接数据库,对应的参数说明: a) 第一个参数我使用的是cx_Oracle,就写这个 b) ...
- JS 鼠标滚轮事件(mousewheel/DOMMouseScroll)
onmousewheel (FireFox不支持此事件) // IE/Opera/Chrome/Safari document.body.onmousewheel = function(event) ...
- sql获取时间
SELECT CONVERT(varchar(10), getdate(), 120)--当前年月日,Example:2013-11-19 SELECT CONVERT(varchar(10), ge ...