Participate in E-sports

版权声明:小白一个,欢迎各位指错。 https://blog.csdn.net/qq_36424540/article/details/82717031

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;
    }
}

猜你喜欢

转载自blog.csdn.net/qq_36424540/article/details/82717031
E
e'e
今日推荐