牛客2021暑期训练1-A-Alice and Bob
牛客2021暑期训练1-A-Alice and Bob
题目链接
题意
给定两堆石子n,m(1<=n,m<=5e3),Alice先手,对任意一堆取k(k>0)个,另一堆取s*k(s>0)个
题解
简单博弈论,设f[i][j]为SG函数值f[0][0]=0,对每个0态枚举k,s,方便起见,令i<=j
代码
#include<bits/stdc++.h>
using namespace std;
const int N=5e3+9;
int T,n,m;
int f[N][N];
void Init()
{for(int i=0;i<=5e3;i++)for(int j=i;j<=5e3;j++)if(!f[i][j]){for(int k=1;i+k<=5e3;k++)for(int s=0;j+s*k<=5e3;s++){int ma=max(i+k,j+s*k);int mi=min(i+k,j+s*k);f[mi][ma]=1;}for(int k=1;j+k<=5e3;k++)for(int s=0;i+s*k<=5e3;s++){int ma=max(j+k,i+s*k);int mi=min(j+k,i+s*k);f[mi][ma]=1;}}
}
int main()
{Init();cin>>T;while(T--){cin>>n>>m;if(n>m) swap(n,m);if(f[n][m]) cout<<"Alice\n";else cout<<"Bob\n";}return 0;
}
牛客2021暑期训练1-A-Alice and Bob相关推荐
- (2021牛客多校一)A.Alice and Bob(博弈)
样例输入: 5 2 3 3 5 5 7 7 5 7 7 Bob Alice Bob Bob Alice 题意:有两堆石子,石子数目分别为n和m,Alice和Bob轮流进行以下操作: 从一堆石子中取出k ...
- 牛客 2021年度训练联盟热身训练赛第二场 I题Pegasus Circle Shortcut
题目描述 For the UCF High School Programming Tournament, the judges were located in the Engineering buil ...
- 牛客 2021年度训练联盟热身训练赛第二场 G题Plate Spinning
文章目录 题目描述 输入描述: 输出描述: 输入 输出 AC的C++代码 题目描述 Plate spinning is a circus act where a person spins variou ...
- 牛客 2021年度训练联盟热身训练赛第二场 E题NIH Budget
文章目录 题目描述 输入描述: 输出描述: 示例1 题目描述 Recently, a job for an algorithms specialist opened up at NIH. You ne ...
- 牛客 2021年度训练联盟热身训练赛第二场 D题Soccer Standings
文章目录 题目描述 输入描述: 输出描述: 输入 输出 题目描述 Soccer fever has gripped the world once again, and millions of peop ...
- 牛客 2021年度训练联盟热身训练赛第二场 C题Tip to be Palindrome
题目描述 One of the cool UCF CS alumni is Dr. Greg, The Palindrome Tipper. A palindrome is a string that ...
- 牛客 2021年度训练联盟热身训练赛第二场 B题
文章目录 题目描述 输入描述: 输出描述: 输入 输出 AC的C++代码: 题目描述 According to the national statistics, a teenager sends/re ...
- 牛客 2021年度训练联盟热身训练赛第二场 A题
题目描述 Professor Boolando can only think in binary, or more specifically, in powers of 2. He converts ...
- 牛客网暑期ACM多校训练营(第十场)F.Rikka with Line Graph
牛客网暑期ACM多校训练营(第十场)F.Rikka with Line Graph 做法:\(G'\) 中的对应原图两条边(a,b) (c,d)的最短路为: \[ w[a][b] + w[c][d] ...
最新文章
- shinyapps安装
- 容器退出时我丢失了数据
- Gear VR推出移动冒险InMind 2
- 静态链表的插入和删除
- python笔记基础-Python入门基础知识学习笔记之一
- 黄金法则----比较法则
- IE下checkbox或radio隐藏bug
- string字符串详解
- windows配置Python多版本共存
- 分类算法之朴素贝叶斯算法
- c# 跨线程访问窗体UI
- struts拦截器+注解实现网络安全要求中的日志审计功能
- springBoot构建Restful webService接口(医院)
- 模2运算 / 模2算法(模2加法、模2减法、模2乘法、模2除法)
- Python+OpenCV实现车牌检测与识别
- MYBATIS 文档
- Java调用soap协议的webservice
- 考研篇:如何在偶数年数学120+(刷同样的题,为什么有人的分数会更高?)
- 百度自然语言接口调用
- 南非SABS EMC CoC简介