hdu 1525 Euclid's Game
来源:互联网 发布:语文句子成分划分软件 编辑:程序博客网 时间:2024/06/16 13:50
给出 a,b , 每个人 可以 将 大的数 可以减去 小的数的倍数,但不能变成负的, 谁先出现 x ,0 的状态 谁赢。
假设 当前可以选择的倍数k 是大于2 的, 那么这个状态就是必胜的。 a,b 转化成 b ,a%b 时, 若b, a%b 是必胜, 只要转化成 a%b+b , b 这个状态。
若 b,a%b 必败, 则 直接转化成 b ,a%b 。
那么 决定先手胜负的就是, 开始的 1 的个数, 因为 当 a, b 只有一种选择时 ,状态只有一种转移,谁先转化到偶数 或者谁先到最有一步,谁赢。
#include <vector>#include <list>#include <map>#include <set>#include <deque>#include <stack>#include <cstring>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio> #include <cstdlib>#include <ctime>#include <assert.h>#include <queue>#define REP(i,n) for(int i=0;i<n;i++)#define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)#define ALLL(x) x.begin(),x.end()#define SORT(x) sort(ALLL(x))#define CLEAR(x) memset(x,0,sizeof(x))#define FILLL(x,c) memset(x,c,sizeof(x))using namespace std; const double EPS = 1e-8;#define LL long long #define pb push_backint a,b;;int tot;int num[100];int gcd(int a,int b){ if(b==0)return a; if(a>=b){ int t = a/b; tot ++ ; num[tot] =t; } return gcd(b,a%b);}int main(){ while(scanf("%d%d",&a,&b),a|b){ tot= 0 ; gcd(a,b); int ans= 0; int st =0; for(int i=1;i<tot;i++){ //if(num[i]>1)ans ++; if(!st && num[i]>1){ st = i; break; }else if(!st){ ans ++; } } if(ans&1){ puts("Ollie wins"); }else{ puts("Stan wins"); } } return 0;}
- hdu 1525 Euclid's Game
- hdu 1525 Euclid's Game
- HDU 1525 - Euclid's Game
- hdu 1525 Euclid's Game
- HDU(1525)Euclid's Game
- HDU 1525 Euclid's Game
- hdu 1525 Euclid's Game
- HDU 1525 Euclid’s Game
- hdu 1525 Euclid's Game
- HDU-1525-Euclid's Game
- HDU 1525 Euclid's Game
- HDU 1525 Euclid's Game (博弈)
- hdu 1525 Euclid's Game 博弈
- [简单博弈] hdu 1525 Euclid's Game
- hdu 1525 Euclid's Game 博弈
- HDU 1525 Euclid's Game 博弈
- HDU 1525 Euclid's Game (博弈)
- HDU 1525 Euclid's Game 博弈
- Lecture 7 自定义类型
- Linux 中make install安装的软件卸载
- Extjs 4.x 中ComboBox级联问题
- java中break,continue和return的区别
- 修复Linux Mint损坏的依赖
- hdu 1525 Euclid's Game
- HDU 2602 Bone Collector (0/1背包问题)
- Linux博文索引
- jQuery zTree v3.5 实例4 对树的节点进行编辑和删除
- 初为项目经理
- POJ 1002多重映射:map的用法
- 【程序3】 题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?
- Itercast中课件整理
- 问答小程序