• 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
    1. #include<bits/stdc++.h>
    2. using namespace std;
    3. int T;
    4. int main(){
    5. scanf("%d",&T);
    6. while (T--)
    7. {
    8. int n,m;
    9. bool flag;
    10. scanf("%d%d",&n,&m);
    11. if(m>=n-1){
    12. if(n%2==0) flag=false;
    13. else flag=true;
    14. }
    15. else flag=true;
    16. if(flag)
    17. cout << "Kilani" << endl;
    18. else
    19. cout << "Ayoub"<<endl;
    20. }
    21. }

    题解:

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

  • 相关阅读:
    一、RocketMQ安装
    java每日一记 —— 谈谈反射
    Postgresql数据库运维统计信息
    深度学习之基础知识
    YOLOV1详解
    Centos7 安装部署Kubernetes(k8s)集群
    Go Mutex(互斥锁)
    android studio 加载html文件(备忘)
    Linux运维:系统日志篇
    React笔记:useState
  • 原文地址:https://blog.csdn.net/QZZ_PP/article/details/125631962