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< ...
随机推荐
- Spring 注解学习 详细代码示例
学习Sping注解,编写示例,最终整理成文章.如有错误,请指出. 该文章主要是针对新手的简单使用示例,讲述如何使用该注释,没有过多的原理解析. 已整理的注解请看右侧目录.写的示例代码也会在结尾附出. ...
- 构建一个拥有sshd服务的docker镜像
不直接描述结果,通过一个过程探究如何写一个 Dockerfile 一.环境 虚拟机CentOS7.4,Docker1.13.1 二.尝试步骤 1.下载基础镜像 docker pull alpine:3 ...
- python8.1多线程
import threadingimport time def run1 (name,sex): print(name,sex,"执行线程1") time.sleep(3)def ...
- JS 前端框架笔记
Swiper轮播图插件使用 官网:https://www.swiper.com.cn/ 先引用插件的css.js文件 然后找到需要使用的轮播图文件中去把HTML css和JS代 ...
- C#LeetCode刷题之#48-旋转图像(Rotate Image)
问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3668 访问. 给定一个 n × n 的二维矩阵表示一个图像. 将 ...
- 【译】gRPC-Web for .NET now available
.NET 的 gRPC-Web 现在正式发布了.我们在一月份发布了实验版,从那时起,我们就根据早期的用户反馈进行着改进. 有了这个版本,gRPC-Web 就变成了 grpc-dotnet 项目的一个完 ...
- 浏览器自动化的一些体会4 webBrowser控件之零碎问题2
1. DocumentCompleted的多次执行问题 有的网页,会多次触发DocumentCompleted事件,由于它是异步的,不会阻塞,所以如果不恰当处理,会造成某些代码被错误地多次执行,造成意 ...
- Python实现电脑控制,这个库让你可以控制和监控输入设备
前言 这个库让你可以控制和监控输入设备.对于每一种输入设备,它包含一个子包来控制和监控该种输入设备:pynput.mouse:包含控制和监控鼠标或者触摸板的类.pynput.keyboard:包含控制 ...
- MySQL经典练习题及答案,常用SQL语句练习50题
表名和字段 –1.学生表 Student(s_id,s_name,s_birth,s_sex) –学生编号,学生姓名, 出生年月,学生性别 –2.课程表 Course(c_id,c_name,t_id ...
- git提交限制后提交出错的暴力解决 (使用小乌龟)
1.右键-> TortoiseGit-> 显示日志 2.右键->重置到哪个版本 3. 重新修改提交信息提交