【POJ】【2348】Euclid‘s Game
博弈论
题解:http://blog.sina.com.cn/s/blog_7cb4384d0100qs7f.html
感觉本题关键是要想到【当a-b>b时先手必胜】,后面的就只跟奇偶性有关了
//POJ 2348
#include<cstdio>
#include<algorithm>
bool game(int a,int b){
if (a%b==) return ;
else if (a-b<b) return !game(b,a-b);
return ;//若a-b>b 则先手必胜
}
int main(){
int a,b;
while(scanf("%d%d",&a,&b)!=EOF){
if (!a && !b) break;
if (a<b) std::swap(a,b);
printf(game(a,b) ? "Stan wins\n" : "Ollie wins\n");
}
return ;
}
【POJ】【2348】Euclid‘s Game的更多相关文章
- 【 POJ - 1204 Word Puzzles】(Trie+爆搜|AC自动机)
Word Puzzles Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 10782 Accepted: 4076 Special ...
- 【POJ 1459 power network】
不可以理解的是,测评站上的0ms是怎么搞出来的. 这一题在建立超级源点和超级汇点后就变得温和可爱了.其实它本身就温和可爱.对比了能够找到的题解: (1)艾德蒙·卡普算法(2)迪尼克算法(3)改进版艾德 ...
- 【POJ 2728 Desert King】
Time Limit: 3000MSMemory Limit: 65536K Total Submissions: 27109Accepted: 7527 Description David the ...
- 【POJ 2976 Dropping tests】
Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 13849Accepted: 4851 Description In a certa ...
- 【POJ 3080 Blue Jeans】
Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 19026Accepted: 8466 Description The Genogr ...
- 【POJ各种模板汇总】(写在逆风省选前)(不断更新中)
1.POJ1258 水水的prim……不过poj上硬是没过,wikioi上的原题却过了 #include<cstring> #include<algorithm> #inclu ...
- 【POJ 3669 Meteor Shower】简单BFS
流星雨撞击地球(平面直角坐标第一象限),问到达安全地带的最少时间. 对于每颗流星雨i,在ti时刻撞击(xi,yi)点,同时导致(xi,yi)和上下左右相邻的点在ti以后的时刻(包括t)不能再经过(被封 ...
- 【POJ 2823 Sliding Window】 单调队列
题目大意:给n个数,一个长度为k(k<n)的闭区间从0滑动到n,求滑动中区间的最大值序列和最小值序列. 最大值和最小值是类似的,在此以最大值为例分析. 数据结构要求:能保存最多k个元素,快速取得 ...
- 【POJ 2406 Power Strings】
Time Limit: 3000MSMemory Limit: 65536K Description Given two strings a and b we define a*b to be the ...
- bzoj 2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...
随机推荐
- iOS - 苹果健康架构 & 基于HealthKit的健康数据的编辑
最近公司需求,研究了一周之久的苹果健康架构,内容包括:资料调研.报告与HealthKit.framework - API,这一研习还在持续进行中.至此,主要认识到了2点:对苹果健康健康架构设计与实现原 ...
- TableViewCell自适应高度
//初始化TableView时设置 self.tv.estimatedRowHeight=54;self.tv.rowHeight=UITableViewAutomaticDimension;
- 【学习笔记】Mac OS X系统介绍
一.Dock *相当于Windows的快速启动栏,用来存放常用软件的图标 *单击软件图标即可打开相应的软件 *右击软件图标还有其他菜单选项:比如退出软件 *图标下边的黑点代表程序正在运行中,并没有完全 ...
- ie、IE兼容模式,提示SCRIPT1028: 缺少标识符、字符串或数字
旧版ie下json最后一项是不允许有逗号的 为了更好的兼容各个浏览器,json最后的逗号最好不加
- OC11_真正的代理
// // ReceiveReportDelegate.h // OC11_真正的代理 // // Created by zhangxueming on 15/6/24. // Copyright ( ...
- tomcat的OutOfMemoryError(PermGen space)解决方法
修改TOMCAT_HOME/bin/catalina.bat,在“echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行: set J ...
- IPC with pipes, demo of 'popen'
#include <stdio.h> #include <unistd.h> int main() { FILE* stream = popen ("sort&quo ...
- C# 带进度条的文件下载
private long fileLength; private long downLength;//已经下载文件大小,外面想用就改成公共属性 private static bool stopDown ...
- AngularJS(14)-动画
AngularJS 提供了动画效果,可以配合 CSS 使用. AngularJS 使用动画需要引入 angular-animate.min.js 库. <!DOCTYPE html> &l ...
- 【转】Linux Framebuffer
全面的framebuffer详解 一.FrameBuffer的原理 FrameBuffer 是出现在 2.2.xx 内核当中的一种驱动程序接口. Linux是工作在保护模式下,所以用户态进程是无法象D ...