B - Road to Arabella(没看懂)

B - Road to Arabellaicon-default.png?t=M5H6https://vjudge.csgrandeur.cn/problem/Gym-102263B

Ayoub and Kilani felt board while they are going to ArabellaCPC in (Amman-Irbid) road, so Kilani invented a new game to play with Ayoub.

The game is described by the following rules :

Ayoub picks a random integer nn (1≤n≤109)(1≤n≤109) , and Kilani picks a random integer kk (1≤k≤n)(1≤k≤n), then they will start playing. In each turn a player can choose any number xx (1≤x≤max(1,m−k))(1≤x≤max(1,m−k)) (which mm is the current value of nn) and subtract it from nn. if nn equals zero then the player can't make a move. The player who can't make a move is considered to lose the game.

If Kilani starts, and each player played optimally, who would be the winner?

Input

First line of input contains integer TT (1≤T≤104)(1≤T≤104) the number of test cases.

Each one of next TT lines contains two integers nn and kk, (1≤k≤n≤109)(1≤k≤n≤109).

Output

print "Kilani" if he wins, and print "Ayoub" otherwise. (the output is case sensitive)

Example

input

Copy

2
2 1
4 1

output

Copy

Ayoub
Kilani
#include<bits/stdc++.h>
using namespace std;
int T;
int main(){
    scanf("%d",&T);
    while (T--)
    {
        int n,m;
        bool flag;
        scanf("%d%d",&n,&m);
        if(m>=n-1){
            if(n%2==0) flag=false;
            else flag=true;
        }
        else flag=true;
        if(flag)
            cout << "Kilani" << endl;
        else
            cout << "Ayoub"<<endl;
    }
}

题解:

当只能选择1的时候是能确定胜负局面的时候。假如k==n或k==n−1,则一开始就确定了胜负,n偶Kilani负,n奇Kilani胜。假如k<n-1,Kilani先手,可以选择一个数使m为偶数,且之后的回合都只能选1,必胜。
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值