Participate in E-sports (开根号)

Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know which one to choose, so they use a way to make decisions.

They have several boxes of candies, and there are ii candies in the i^{th}ith box, each candy is wrapped in a piece of candy paper. Jessie opens the candy boxes in turn from the first box. Every time a box is opened, Jessie will take out all the candies inside, finish it, and hand all the candy papers to Justin.

When Jessie takes out the candies in the N^{th}Nthbox and hasn't eaten yet, if the amount of candies in Jessie's hand and the amount of candy papers in Justin's hand are both perfect square numbers, they will choose Arena of Valor. If only the amount of candies in Jessie's hand is a perfect square number, they will choose Hearth Stone. If only the amount of candy papers in Justin's hand is a perfect square number, they will choose Clash Royale. Otherwise they will choose League of Legends.

Now tell you the value of NN, please judge which game they will choose.

Input

The first line contains an integer T(1 \le T \le 800)T(1≤T≤800) , which is the number of test cases.

Each test case contains one line with a single integer: N(1 \le N \le 10^{200})N(1≤N≤10200) .

Output

For each test case, output one line containing the answer.

样例输入复制

4
1
2
3
4

样例输出复制

Arena of Valor
Clash Royale
League of Legends
Hearth Stone
import java.math.*;
import java.util.*;

public class Main{
    public static void main(String[] args) {
        // 计算2**128+1
    	Scanner cin=new Scanner(System.in);
    	while(cin.hasNext()){
    		int T=cin.nextInt();
    		for(int kase=1;kase<=T;kase++){
    			
    			BigInteger two=BigInteger.valueOf(2);
    			BigInteger n=cin.nextBigInteger();
    			BigInteger sum=n.multiply(n.subtract(BigInteger.ONE)).divide(two);
    			
    			boolean f1=is_square(n),f2=is_square(sum);
    			
    			BigInteger a=BigInteger.ONE; BigInteger b=BigInteger.ONE;
    			
    			if(f1&&f2){
    				System.out.println("Arena of Valor");
    			}
    			else if(f1&&!f2){
    				System.out.println("Hearth Stone");
    			}
    			else if(!f1&&f2){
    				System.out.println("Clash Royale");
    			}
    			else{
    				System.out.println("League of Legends");
  
    			}
    		}
    	}
    }
    public static boolean is_square(BigInteger n){

    	if(n.equals(BigInteger.ZERO))return true;
    	
    	BigInteger two=BigInteger.valueOf(2);

    	BigInteger low=BigInteger.ONE,high=n,mid;
    	while(low.compareTo(high)<=0){
    		//mid=low.add(high).shiftRight(1);//一定得用移位,不能用divide(two),还是菜啊
    		
    		mid=mid=low.add(high).shiftRight(1);
    		BigInteger tmp=mid.multiply(mid);
    		if(tmp.equals(n))
    			return true;
    		if(tmp.compareTo(n)>0){
    			high=mid.subtract(BigInteger.ONE);
    		}
    		if(tmp.compareTo(n)<0){
    			low=mid.add(BigInteger.ONE);
    		}
    		//mid=low.add(high).shiftRight(1);
    	}
    	return false;
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值