牛客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相关推荐

  1. (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 ...

  2. 牛客 2021年度训练联盟热身训练赛第二场 I题Pegasus Circle Shortcut

    题目描述 For the UCF High School Programming Tournament, the judges were located in the Engineering buil ...

  3. 牛客 2021年度训练联盟热身训练赛第二场 G题Plate Spinning

    文章目录 题目描述 输入描述: 输出描述: 输入 输出 AC的C++代码 题目描述 Plate spinning is a circus act where a person spins variou ...

  4. 牛客 2021年度训练联盟热身训练赛第二场 E题NIH Budget

    文章目录 题目描述 输入描述: 输出描述: 示例1 题目描述 Recently, a job for an algorithms specialist opened up at NIH. You ne ...

  5. 牛客 2021年度训练联盟热身训练赛第二场 D题Soccer Standings

    文章目录 题目描述 输入描述: 输出描述: 输入 输出 题目描述 Soccer fever has gripped the world once again, and millions of peop ...

  6. 牛客 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 ...

  7. 牛客 2021年度训练联盟热身训练赛第二场 B题

    文章目录 题目描述 输入描述: 输出描述: 输入 输出 AC的C++代码: 题目描述 According to the national statistics, a teenager sends/re ...

  8. 牛客 2021年度训练联盟热身训练赛第二场 A题

    题目描述 Professor Boolando can only think in binary, or more specifically, in powers of 2. He converts ...

  9. 牛客网暑期ACM多校训练营(第十场)F.Rikka with Line Graph

    牛客网暑期ACM多校训练营(第十场)F.Rikka with Line Graph 做法:\(G'\) 中的对应原图两条边(a,b) (c,d)的最短路为: \[ w[a][b] + w[c][d] ...

最新文章

  1. shinyapps安装
  2. 容器退出时我丢失了数据
  3. Gear VR推出移动冒险InMind 2
  4. 静态链表的插入和删除
  5. python笔记基础-Python入门基础知识学习笔记之一
  6. 黄金法则----比较法则
  7. IE下checkbox或radio隐藏bug
  8. string字符串详解
  9. windows配置Python多版本共存
  10. 分类算法之朴素贝叶斯算法
  11. c# 跨线程访问窗体UI
  12. struts拦截器+注解实现网络安全要求中的日志审计功能
  13. springBoot构建Restful webService接口(医院)
  14. 模2运算 / 模2算法(模2加法、模2减法、模2乘法、模2除法)
  15. Python+OpenCV实现车牌检测与识别
  16. MYBATIS 文档
  17. Java调用soap协议的webservice
  18. 考研篇:如何在偶数年数学120+(刷同样的题,为什么有人的分数会更高?)
  19. 百度自然语言接口调用
  20. 南非SABS EMC CoC简介

热门文章

  1. 深耕本地资源打造智慧城市
  2. mysql 冷数据存储_数据冷存储系统:更加高效的海量数据存储解决方案
  3. 小波变换在图像压缩方面的分析与应用(Matlab代码)
  4. 【首尔大学韩国语】十四课 快走吧
  5. 通过winscp软件实现windows与linux目录数据同步
  6. ReactNative数组操作
  7. 创建自签名证书命令异常记录
  8. frp进行内网穿透【转载】
  9. python之类的构造方法
  10. Day_14 less,scss,stylus