1066 Bash游戏

1066 Bash游戏

基准时间限制:秒 空间限制:131072 KB

有一堆石子共有N个。A B两个人轮流拿,A先拿。每次最少拿1颗,最多拿K颗,拿到最后1颗石子的人获胜。假设A B都非常聪明,拿石子的过程中不会出现失误。给出NK,问最后谁能赢得比赛。

例如N = 3K = 2。无论A如何拿,B都可以拿到最后1颗石子。

Input

1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 10000)

2 - T + 1行:每行2个数NK。中间用空格分隔。(1 <= N,K <= 10^9)

Output

T行,如果A获胜输出A,如果B获胜输出B

Input示例

4

3 2

4 2

7 3

8 3

Output示例

B

A

A

B

import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            int n=sc.nextInt();
            int k=sc.nextInt();
            if(n%(k+1)==0)
                System.out.println("B");
            else
                System.out.println("A");
        }
        sc.close();

    }

}
原文地址:https://www.cnblogs.com/watchfree/p/5350726.html