51Nod 博弈模板题
连刷3道博弈模板题,算是稍微学习了以下三个经典博弈了。推荐一个博客。
第一道模板:Bash博弈——同余理论
第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 10000)
第2 - T + 1行:每行2个数N,K。中间用空格分隔。(1 <= N,K <= 10^9)
共T行,如果A获胜输出A,如果B获胜输出B。
4
3 2
4 2
7 3
8 3
B
A
A
B
//Asimple
#include <bits/stdc++.h>
//#define INF 0x3fffffff
#define swap(a,b,t) t = a, a = b, b = t
#define CLS(a, v) memset(a, v, sizeof(a))
#define debug(a) cout << #a << " = " << a <<endl
#define test() cout<<"=========="<<endl
using namespace std;
typedef long long ll;
const int maxn = +;
const double PI=acos(-1.0);
//const ll mod = 1000005;
const int INF = ( << ) ;
const int dx[] = {-, , , };
const int dy[] = { ,-, , };
ll n, m, res, ans, len, T, k, num, sum;
ll mod; void input() {
ios_base::sync_with_stdio(false);
cin >> T;
while( T -- ) {
cin >> n >> m;
if( n%(m+)!= ) cout << "A" << endl;
else cout << "B" << endl;
}
} int main(){
input();
return ;
}
第二道:Nim游戏——异或理论
第1行:一个数N,表示有N堆石子。(1 <= N <= 1000)
第2 - N + 1行:N堆石子的数量。(1 <= A[i] <= 10^9)
如果A获胜输出A,如果B获胜输出B。
3
1
1
1
A
//Asimple
#include <bits/stdc++.h>
//#define INF 0x3fffffff
#define swap(a,b,t) t = a, a = b, b = t
#define CLS(a, v) memset(a, v, sizeof(a))
#define debug(a) cout << #a << " = " << a <<endl
#define test() cout<<"=========="<<endl
using namespace std;
typedef long long ll;
const int maxn = +;
const double PI=acos(-1.0);
const ll mod = ;
const int INF = ( << ) ;
const int dx[] = {-, , , };
const int dy[] = { ,-, , };
ll n, m, res, ans, len, T, k, num, sum;
//ll mod; void input() {
ios_base::sync_with_stdio(false);
while( cin >> n ) {
ans = ;
for(int i=; i<n; i++) {
cin >> num;
ans ^= num;
}
if( !ans ) cout << "B" << endl;
else cout << "A" << endl;
}
} int main(){
input();
return ;
}
第三道:威佐夫游戏——黄金分割
第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 10000)
第2 - T + 1行:每行2个数分别是2堆石子的数量,中间用空格分隔。(1 <= N <= 2000000)
共T行,如果A获胜输出A,如果B获胜输出B。
3
3 5
3 4
1 9
B
A
A
//Asimple
#include <bits/stdc++.h>
//#define INF 0x3fffffff
#define swap(a,b,t) t = a, a = b, b = t
#define CLS(a, v) memset(a, v, sizeof(a))
#define debug(a) cout << #a << " = " << a <<endl
#define test() cout<<"=========="<<endl
using namespace std;
typedef long long ll;
const int maxn = +;
const double PI=acos(-1.0);
const ll mod = ;
const int INF = ( << ) ;
const int dx[] = {-, , , };
const int dy[] = { ,-, , };
ll n, m, res, ans, len, T, k, num, sum, t;
ll a[maxn];
//ll mod; void input() {
ios_base::sync_with_stdio(false);
cin >> T;
while( T -- ){
cin >> n >> m;
if( n>m ) {
t = n; n = m; m = t;
}
t = floor((m-n)*(+sqrt(5.0))/);
if( t == n ) cout << "B" << endl;
else cout << "A" << endl;
}
} int main(){
input();
return ;
}
51Nod 博弈模板题的更多相关文章
- 最大子矩阵和 51Nod 1051 模板题
一个M*N的矩阵,找到此矩阵的一个子矩阵,并且这个子矩阵的元素的和是最大的,输出这个最大的值. 例如:3*3的矩阵: -1 3 -1 2 -1 3 -3 1 2 和最大的子矩阵是: 3 - ...
- 51nod 1028 大数乘法 V2 【FFT模板题】
题目链接 模板题.. #include<bits/stdc++.h> using namespace std; typedef int LL; typedef double db; nam ...
- 51nod 1086背包问题V2 (完全背包模板题)
1086 背包问题 V2 1 秒 131,072 KB 20 分 3 级题 题目描述 有N种物品,每种物品的数量为C1,C2......Cn.从中任选若干件放在容量为W的背包里,每种物品的体积为W1, ...
- [AHOI 2009] 维护序列(线段树模板题)
1798: [Ahoi2009]Seq 维护序列seq Time Limit: 30 Sec Memory Limit: 64 MB Description 老师交给小可可一个维护数列的任务,现在小 ...
- HDU 2222 AC自动机模板题
题目: http://acm.hdu.edu.cn/showproblem.php?pid=2222 AC自动机模板题 我现在对AC自动机的理解还一般,就贴一下我参考学习的两篇博客的链接: http: ...
- POJ2774 & 后缀数组模板题
题意: 求两个字符串的LCP SOL: 模板题.连一起搞一搞就好了...主要是记录一下做(sha)题(bi)过程心(cao)得(dan)体(xin)会(qing) 后缀数组概念...还算是简单的,过程 ...
- HDU 1251 Trie树模板题
1.HDU 1251 统计难题 Trie树模板题,或者map 2.总结:用C++过了,G++就爆内存.. 题意:查找给定前缀的单词数量. #include<iostream> #incl ...
- HDU-3549 最大流模板题
1.HDU-3549 Flow Problem 2.链接:http://acm.hdu.edu.cn/showproblem.php?pid=3549 3.总结:模板题,参考了 http://ww ...
- HDU 4280:Island Transport(ISAP模板题)
http://acm.hdu.edu.cn/showproblem.php?pid=4280 题意:在最西边的点走到最东边的点最大容量. 思路:ISAP模板题,Dinic过不了. #include & ...
随机推荐
- 【Zookeeper系列】zookeeper面试题(转)
原文链接:https://segmentfault.com/a/1190000014479433 1.ZooKeeper是什么? ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是 ...
- PowerBI与Visio
前言 如何在Power BI中使用Visio, 刚好最近微软推出了适用于Power BI 的 Visio自定义可视化对象预览,分享给大家. 我们先看一下效果: 通过自定义可视化对象,将Visio ...
- PCB画板总结
最近几天完成了第一个PCB电路板.虽然器件不是很多,手动布线了4次才达到自己理想的效果. 但是还是有很多细节只有亲自拿到了自己做的板子,亲自焊接之后,才知道自己哪里不合适. 这是修改了4次之后的最终的 ...
- Solve Docker for Windows error: docker detected, A firewall is blocking file Sharing between Windows and the containers
被这个“分享硬盘”问题烦了我好几个小时,终于在一个叫Marco Mansi外国人博客上找到解决方法了,真的很无奈 https://blog.olandese.nl/2017/05/03/solve-d ...
- linux 安装配置nexus以及maven私服应用
---------------------nexus---------------------- 1.编辑nexus脚本, 配置 RUN_AS_USER 参数vi /usr/local/src/nex ...
- Nestjs 上传文件
Docs: https://docs.nestjs.com/techniques/file-upload 上传单文件 @Post('upload') @UseInterceptors(FileInte ...
- vue利用vue ui命令创建项目
上次用git bash,用create 命令创建vue项目,这是玩个炫酷的------vue ui (前提是有安装node.js). 在目标文件 vue ui 可以看到他在8000端口出现了一个gu ...
- [daily] 比端口转发更高级的ssh device tunnel转发
没有什么能够阻挡,你对自由的向往. 场景: 我有一台设备Server100,在某一个f复杂的内网里,需要多次ssh跳转可以访问到.但是它不能直接访问internet. 我现在需要在我的ssh路径上,搭 ...
- [qemu] qemu从源码编译安装
环境:CentOS7-1804 下载最新的源码: ┬─[tong@T7:~/Src/thirdparty/PACKAGES]─[:: AM] ╰─>$ axel https://download ...
- 从光盘安装ubuntu系统
参考博客: https://www.jianshu.com/p/7929e4911206