1066 Bash游戏

有一堆石子共有N个。A B两我的轮流拿,A先拿。每次最少拿1颗,最多拿K颗,拿到最后1颗石子的人获胜。假设A B都很是聪明,拿石子的过程当中不会出现失误。给出N和K,问最后谁能赢得比赛。
例如N = 3,K = 2。不管A如何拿,B均可以拿到最后1颗石子。
Input
第1行:一个数T,表示后面用做输入测试的数的数量。(1 <= T <= 10000)
第2 - T + 1行:每行2个数N,K。中间用空格分隔。(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
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#define range(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
#define rerange(i,a,b) for(int i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
using namespace std;
int T;
void init() {
    cin>>T;
}
void solve(){
    while(T--){
        int n,m;
        cin>>n>>m;
        cout<<(n%(m+1)?'A':'B')<<endl;
    }
}
int main() {
    init();
    solve();
    return 0;
}
View Code
相关文章
相关标签/搜索