1068 Bash游戏 V3 51 Nod 1068 Bash游戏v3

题目来源: Ural 1180

基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题

51 Nod 1068 Bash游戏v3 收藏

51 Nod 1068 Bash游戏v3 关注

有一堆石子共有N个。A B两个人轮流拿,A先拿。每次拿的数量只能是2的正整数次幂,比如(1,2,4,8,16....),拿到最后1颗石子的人获胜。假设A B都非常聪明,拿石子的过程中不会出现失误。给出N,问最后谁能赢得比赛。

例如N = 3。A只能拿1颗或2颗,所以B可以拿到最后1颗石子。(输入的N可能为大数)

Input

第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 1000)
第2 - T + 1行:每行1个数N。(1 <= N <= 10^1000)

Output

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

Input示例

3
2
3
4

Output示例

A
B
A
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;

public class Main {
	public static void main(String[] args) throws FileNotFoundException
	{
		//System.setIn(new BufferedInputStream(new FileInputStream("J_in.txt")));
		Scanner cin=new Scanner(new BufferedInputStream(System.in));
		BigInteger n;
		int t;
		t=cin.nextInt();
		while(t>0)
		{
			t--;
			n=cin.nextBigInteger();
			n=n.subtract(new BigInteger("1"));
			n=n.mod(new BigInteger("3"));
			if(n.equals(new BigInteger("0"))){System.out.println("A");}
			else if(n.equals(new BigInteger("1")))System.out.println("A");
			else System.out.println("B");
		}
	}
}

 

相关文章:

  • 2022-12-23
  • 2021-06-28
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
相关资源
相似解决方案