减去两数差值的Euclid’s Game

题目大意

A和B比赛,玩家必须在棋盘上写上一个正数,该数字等于棋盘上已有的两个数字的差值;
这个数字必须是新的,即与主板上已有的所有数字不同。无法移动的玩家输掉游戏。
A先手

思路

判断较大值除以两数的最大公约数的奇偶性即可

AC Code

#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<math.h>
using namespace std;
#define endl '\n'
#define INF 0x3f3f3f3f
// #define int long long
#define debug(a) cout<<#a<<"="<<a<<endl;
typedef long long ll;
const double PI=acos(-1.0);
const double e=exp(1.0);
const int M=1e9+7;
const int N=2e5+7;
inline int mymax(int x,int y){return x>y?x:y;}
inline int mymin(int x,int y){return x<y?x:y;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);
}
void solve(){int n, m;while(~scanf("%d%d", &n, &m) && n && m){if(n<m) swap(n,m);if((n/gcd(n,m))&1)  cout<<"Stan wins"<<endl;else                cout<<"Ollie wins"<<endl;}return ;
}signed main(){solve();return 0;
}

减去两数倍数的Euclid’s Game

题目传送门

Euclid’s Game

题目大意

Stan wins和Stan wins进行比赛,给定两个数,每次将两个数中较大的那个减去较小的那个数的整数倍,减去后依然为正整数
直到两个数有一个数为0,先到0的胜利。
Stan wins先手

思路

第一次遇见可以选择的人将获胜
即为当a≥2∗ba≥2*ba≥2∗b的时候,可以选择转移到(a%b,b)(a\%b,b)(a%b,b)或者(a%b+b,b)(a\%b+b,b)(a%b+b,b)从而产生不同的局势,而这个人足够聪明所以他可以判断出必胜态
所以我们需要找到面临情况这个的人

AC Code

#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<math.h>
using namespace std;
#define endl '\n'
#define INF 0x3f3f3f3f
// #define int long long
#define debug(a) cout<<#a<<"="<<a<<endl;
typedef long long ll;
const double PI=acos(-1.0);
const double e=exp(1.0);
const int M=1e9+7;
const int N=2e5+7;
inline int mymax(int x,int y){return x>y?x:y;}
inline int mymin(int x,int y){return x<y?x:y;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);
}
void solve(){int n, m;while(~scanf("%d%d", &n, &m) && (n||m)){if(n<m) swap(n,m);int flag=1;while(1){if(n%m==0||m==0||n>=2*m) break;int t=n;n=m;m=t-m;flag^=1;}if(flag)    cout<<"Stan wins"<<endl;else        cout<<"Ollie wins"<<endl;}return ;
}signed main(){solve();return 0;
}

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. NUC1445 Euclid's Game【博弈】

    Euclid's Game 时间限制: 1000ms 内存限制: 65535KB 问题描述 Two players, Stan and Ollie, play, starting with two n ...

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

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

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

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

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

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

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

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

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

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

  10. Game Theory: 公平博弈

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

最新文章

  1. ORACLE穿透防火墙问题
  2. Gradle sync failed: Minimum supported Gradle version is 3.3.Current version is 3.2
  3. MyBatis 缓存详解-开启二级缓存的方法
  4. Mysql数据库(一)——mysql数据库初体验
  5. 学会拐弯,才是人生大智慧(深度好文)
  6. endl与'\n'的区别
  7. 立潮头,冲击 “世界一流”——北大建设世界一流数学学科纪实
  8. 深圳南山区法院受理11人集体诉腾讯案
  9. vs xgb 神经网络_业界 | 深度学习与XGBoost在小数据集上的测评,你怎么看?(附源码)...
  10. 花书+吴恩达深度学习(十六)序列模型之双向循环网络 BRNN 和深度循环网络 Deep RNN
  11. electron sqlite3_Electron+React+Antd工程搭建
  12. 【LINUX 学习】查看和修改主机名
  13. Java语言中String累的总结
  14. SQL Server安装教程
  15. 苹果越狱后怎么还原_iOS 13.3 越狱提升稳定性,自签又可以使用了
  16. g2o:一种图优化的C++框架
  17. jquery版本问题
  18. 华为网络设备-访问控制列表配置实验
  19. 请你说一说红黑树的性质还有左右旋转
  20. 技术岗的职业规划_技术人员职业规划精选范文

热门文章

  1. vSphere7.0添加第三方驱动
  2. outlook登陆Exchange邮箱不断掉线并弹出需要登陆的窗口
  3. 5G商用元年开启万亿市场, 25G服务器端口出货量大幅增长
  4. Android后台播放音乐(含通知栏操作)
  5. 新发的日常小实验——Ubuntu安装拼音输入法
  6. TypeError: parentComponent.ctx.deactivate is not a function
  7. 虚拟机(vmware)linux中ctrl按键失灵 解决办法
  8. Gym100015 I Identity Checker 栈容器使用,数学
  9. 如何为摇滚音乐选择吉他音箱,创作原创音乐
  10. 安卓投屏大师_好用的投屏软件合集—2020年