Codeforces 1194D. 1-2-K Game
先考虑只能走 $1,2$ 步的情况,设 $p[i]$ 表示当 $n=i$ 时先手是否必胜
自己手玩一下发现 $p$ 就是 $011011011...011$ 这样循环(下标从 $0$ 开始,其中 $1$ 表示先手必胜)
然后发现当 $K$ 不是 $3$ 的倍数时,对 $p$ 没有影响,因为一个必败局面仍然只能到达必胜局面,必胜局面仍然可以到达必败局面
然后考虑 $K$ 为 $3$ 的倍数时,那么 $p[K]$ 就从 $0$ 变成了 $1$,之后从 $p[K+1]$ 开始又是一段 $011011...011$ 直到 $p[2K]$
所以根据找到的规律判断即可
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=; char ch=getchar();
while(ch<''||ch>'') { if(ch=='-') f=-; ch=getchar(); }
while(ch>=''&&ch<='') { x=(x<<)+(x<<)+(ch^); ch=getchar(); }
return x*f;
}
int main()
{
int Q,n,m;
Q=read();
while(Q--)
{
n=read(),m=read();
if(m%||n<m) { if(n%) printf("Alice\n"); else printf("Bob\n"); continue; }
if(n==m) { printf("Alice\n"); continue; }
if(n%(m+)==m) printf("Alice\n");
else if((n%(m+))%) printf("Alice\n");
else printf("Bob\n");
}
return ;
}
Codeforces 1194D. 1-2-K Game的更多相关文章
- Codeforces Gym 100610 Problem K. Kitchen Robot 状压DP
Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10061 ...
- Codeforces - 1194D - 1-2-K Game - dp
https://codeforc.es/contest/1194/problem/D 打个n=30的表好像看出了规律. 其实假设k==3,那么 sg[0]=0, sg[1]=mex{sg[0]}=1, ...
- Codeforces Gym100495 B、D、E、F、K
http://codeforces.com/gym/100495 K题 草地的面积减去相交的面积,计算几何,垃圾题,避免不必要的计算损失精度(能约分的约分) 卡了老子一个星期了 再加前几天的一道题 这 ...
- Codeforces Problem 708A Letters Cyclic Shift
题目链接: http://codeforces.com/problemset/problem/708/A 题目大意: 从字符串s中挑选出一个子串(非空),将该子串中的每个字母均替换成前一个字母,如' ...
- [短期持续更新]Codeforces 构造题一览
说实话我觉得做这种题很没意思(不够硬核), 可是人有短板终究是要补的...起码这种类型补起来相对简单 所以还是把先前准备好的专题放下吧,做点实现上比较休闲的题 ps.为了精简篇幅,代码全部丢到ubun ...
- Codeforces Global Round 8 B. Codeforces Subsequences(构造)
题目链接:https://codeforces.com/contest/1368/problem/B 题意 构造最短的至少含有 $k$ 个 $codeforces$ 子序列的字符串. 题解 如下表: ...
- 2018省赛赛第一次训练题解和ac代码
第一次就去拉了点思维很神奇的CF题目 2018省赛赛第一次训练 # Origin Title A CodeForces 607A Chain Reaction B CodeForces ...
- 2019-2020 10th BSUIR Open Programming Championship. Semifinal
2019-2020 10th BSUIR Open Programming Championship. Semifinal GYM链接https://codeforces.com/gym/103637 ...
- django模型操作
Django-Model操作数据库(增删改查.连表结构) 一.数据库操作 1.创建model表
随机推荐
- rabbitmq访问控制试坑篇
访问控制我理解就是两层,第一层是Virtual host,相当于一个个独立主机 第二层是这个permissions,对照下图权限表 权限表(重要!) 需求 configgure write read ...
- 小程序web-view利用url给内嵌的网页传值
这个方法跟网页上的一样,直接通过截取url中传过来的参数来取值 <web-view src="https://www.baidu.com/test.html?url=http://ww ...
- The remote system refused the connection.
使用SecureCRT连接Ubuntu时,报错: The remote system refused the connection. 说明Ubuntu上没有安装openssh-server,使用命令: ...
- Python关于%matplotlib inline
Python关于%matplotlib inline %matplotlib inline 是一个魔法函数(Magic Functions).官方给出的定义是:IPython有一组预先定义好的所谓的魔 ...
- [go]os.Open方法源码
file, err := os.Open("./buf.go") func Open(name string) (*File, error) { return OpenFile(n ...
- System 源码阅读
System 属性说明 /** * System 类包含了几个有用的字段和方法,并且不能被实例化. * * @author unascribed * @since 1.0 */ public fina ...
- mongodb增删改查操作
Note:mongodb存储的是文档,且文档是json格式的对象,所以增删改查都必须是json格式对象. 注:mongodb常用库和表操作,但mongodb在插入数据时,不需要先创建表. show d ...
- System.Windows.Forms.Timer、System.Timers.Timer、System.Threading.Timer的差别和分别什么时候用
System.Windows.Forms.Timer.System.Timers.Timer.System.Threading.Timer的 区别和用法http://space.itpub.net/1 ...
- jenkins+git+gitlab+ansible实现持续集成自动化部署
一.环境配置 192.168.42.8部署gitlab,节点一 192.168.42.9部署git,Jenkins,ansible服务器 192.168.42.10节点二 二.操作演示 ①gitlab ...
- Linux 部署 Django 系统
一:安装uwsgi pip3 install uwsgi 二:进入项目目录下,创建uwsgi.ini配置文件 [uwsgi] # 使用nginx连接时使用功能,上线时才使用socket,指定项目执行的 ...