Educational Codeforces Round 68 (Rated for Div. 2)-D. 1-2-K Game
standard output
Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. There is a chip placed in the n-th cell (the last one).
Players take turns, Alice is first. Each player during his or her turn has to move the chip 1, 2 or k cells to the left (so, if the chip is currently in the cell i, the player can move it into cell i - 1, i - 2 or i - k). The chip should not leave the borders of the paper strip: it is impossible, for example, to move it k cells to the left if the current cell has number i < k. The player who can't make a move loses the game.
Who wins if both participants play optimally?
Alice and Bob would like to play several games, so you should determine the winner in each game.
The first line contains the single integer T (1 ≤ T ≤ 100) — the number of games. Next T lines contain one game per line. All games are independent.
Each of the next T lines contains two integers n and k (0 ≤ n ≤ 109, 3 ≤ k ≤ 109) — the length of the strip and the constant denoting the third move, respectively.
For each game, print Alice if Alice wins this game and Bob otherwise.
4
0 3
3 3
3 4
4 4
Bob
Alice
Bob
Alice
代码:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+;
typedef long long ll;
using namespace std; int main()
{
int T;
scanf("%d", &T);
while (T--)
{
int n, k;
scanf("%d%d", &n, &k);
if (k == )
{
if(n%!=)
{
puts("Alice\n");
}
else
{
puts("Bob");
}
}
else if (k % == )
{
n %= (k + );
if (n % == && n != k)
puts("Bob");
else
puts("Alice");
}
else
{
if(n%!=)
{
puts("Alice\n");
}
else
{
puts("Bob");
}
}
}
}
Educational Codeforces Round 68 (Rated for Div. 2)-D. 1-2-K Game的更多相关文章
- Educational Codeforces Round 68 (Rated for Div. 2)---B
http://codeforces.com/contest/1194/problem/B /* */ # include <bits/stdc++.h> using namespace s ...
- Educational Codeforces Round 68 (Rated for Div. 2)补题
A. Remove a Progression 签到题,易知删去的为奇数,剩下的是正偶数数列. #include<iostream> using namespace std; int T; ...
- Educational Codeforces Round 68 (Rated for Div. 2) C. From S To T (字符串处理)
C. From S To T time limit per test1 second memory limit per test256 megabytes inputstandard input ou ...
- Educational Codeforces Round 68 (Rated for Div. 2) D. 1-2-K Game (博弈, sg函数,规律)
D. 1-2-K Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input ou ...
- Educational Codeforces Round 68 (Rated for Div. 2)D(SG函数打表,找规律)
#include<bits/stdc++.h>using namespace std;int sg[1007];int main(){ int t; cin>>t; while ...
- Educational Codeforces Round 68 (Rated for Div. 2)-C-From S To T
You are given three strings ss, tt and pp consisting of lowercase Latin letters. You may perform any ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
随机推荐
- Meow 攻击会删除不安全(开放的)的Elasticsearch(及MongoDB) 索引,然后建一堆以Meow结尾的奇奇怪怪的索引(如:m3egspncll-meow)
07月29日,早上照例一来,先连接Elasticsearch查看日志[禁止转载,by @CoderBaby],结果,咦,什么情况,相关索引被删除了,产生了一堆以Meow开头的奇奇怪怪的索引,如下图: ...
- 一文搞定Python正则表达式
本文对正则表达式和 Python 中的 re 模块进行详细讲解 很多人学习python,不知道从何学起.很多人学习python,掌握了基本语法过后,不知道在哪里寻找案例上手.很多已经做案例的人,却不知 ...
- 12、Java 正则表达式
简介 用来描述或者匹配一系列符合某个语句规则的字符串 正则表达式定义了字符串的模式. 正则表达式可以用来搜索.编辑或处理文本. 正则表达式并不仅限于某一种语言,但是在每种语言中有细微的差别. 一.正则 ...
- Java单元测试 Junit TestNG之介绍
Junit是Java中默认的单元测试框架,通过注解的方式去识别测试方法 JUnit4 JUnit4通过注解的方式来识别测试方法.目前支持的主要注解有: @BeforeClass 全局只会执行一次,而且 ...
- (数据科学学习手札92)利用query()与eval()优化pandas代码
本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 利用pandas进行数据分析的过程,不仅仅是计算 ...
- 解决drf_yasg中的SwaggerAPI无法正确分组问题
swagger是后台开发中很好用的交互式文档,Django原本的Django-Swagger已经停止维护了,现在一般用drf_yasg这个包来实现文档,它里面支持swagger和redoc两种,red ...
- CornerNet
论文 CornerNet: Detecting Objects as Paired Keypoint
- PMP各种图比较记忆
1.控制图:监控过程是否稳定,是否具有可预测的绩效,在问题还未发生时解决.需要关注控制图中的平均值.控制界限.规格界限的含义.控制上.下限一般设为±3个西格玛.过程失控的情况包括数据点在控制界限外,以 ...
- MySQL数据库安装,MySQL数据库库的增删改查,表的增删改查,表数据的基本数据类型
一 MySQL的安装 MySQL现在属于甲骨文公司,所以和java语言匹配度较高,同时甲骨文公司的另一种数据库为Oracle,两者同为关系型数据库,即采用关系模型来组织数据,以行和列的方法来存储数据的 ...
- NodeJs nrm 和 nvm
nrm 和 nvm nrm (npm registry manager)是npm的镜像源管理工具 nvm (node version manager)是nodejs的版本管理工具 nrm # nrm ...