D. 1-2-K Game

链接:https://codeforces.com/contest/1194/problem/D

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&nbs***bsp;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&nbs***bsp;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.

Input

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.

Output

For each game, print Alice if Alice wins this game and Bob otherwise.

Example

input

Copy

4
0 3
3 3
3 4
4 4

output

Copy

Bob
Alice
Bob
Alice

代码:

#include<bits/stdc++.h>
using namespace std;
long long n,t,l,j,r,k,d,ans,max1=0,mod=1e9+7;
long long a[200005],b[200005];
map<long long,long long>m;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n>>k;
		if(n==0)
		cout<<"Bob"<<endl;
		else
		{
			if(k%3==0)
			n%=(k+1);
			if(n==k||n%3==2||n%3==1)
			cout<<"Alice"<<endl;
			else 
			cout<<"Bob"<<endl;
		}
		
	}
	
} 

 

全部评论

相关推荐

2025年10月3日中午,在写完定时一年后发给自己的信之后,敲下键盘,写下这篇文字。我把标题的“所有人”加了引号,因为如我们所见,确实有的人顺风顺水,每天过的很开心,或是早早进入大厂,或是年纪轻轻就拿到了高薪offer,或是过着可能我努力十年也不一定实现的生活。但也许,不是每个人的痛苦都能被别人看到的,这个月我经常会哭,被骗6000块钱、手上钱不够导致拖欠房租、生活还要借朋友钱、国庆长假也没有钱去旅游,互联网公司不稳定担心试用期不过(毕竟上段实习就是被裁了,一有点风吹草动就害怕),但这样的我,不是所有人都知道的,居然是有些朋友的羡慕对象。回忆我的七年“长跑”别人都是多年幸福的恋爱长跑,我没有恋...
故事和酒66:让每一颗种子找到合适自己的生长方式,最终绽放出独一无二的花朵,这远比所有人都被迫长成同一棵“参天大树”的世界,更加美好和富有生机。这是社会和环境的问题,而不是我们的问题。然而就是在这样的环境中,楼主依然能突破自我,逆势成长,其中的艰辛可想而知。这一路的苦难终究会化作你成长的养料
你小时候最想从事什么职业
点赞 评论 收藏
分享
08-12 07:02
中南大学 C++
您所拨打的号码无法接...:之前的经验是:鹅首先会根据你的意向放在意向部门池子里捞,如果没捞则进入大池子。能够快速捞起的最好方法就是每天刷新简历,不停刷直到有面试邀约为止。
投递腾讯等公司10个岗位
点赞 评论 收藏
分享
面试拷打成m:我感觉他说的挺对的,感觉我找不到工作也要去送外卖了,至少饿不死
点赞 评论 收藏
分享
昨天 16:23
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务