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
i candies in the
ithi^{th}
i
th
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
NthN^{th}
N
th
box 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
N, please judge which game they will choose.
Input
The first line contains an integer
T(1≤T≤800)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≤N≤10200)N(1 \le N \le 10^{200})
N(1≤N≤10
200
) .
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
java 的大整数以及牛顿迭代求平方根即可;
… >>1 不会T,/2会T( orz )。。。
import org.omg.CORBA.PUBLIC_MEMBER;
import java.math.*;
import java.time.chrono.*;
import java.util.Calendar;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
int t=cin.nextInt();
for(int i=0;i<t;i++) {
BigInteger n=cin.nextBigInteger();
BigInteger xx=cal(n);
BigInteger y=n.multiply(n.subtract(BigInteger.valueOf(1))).divide(BigInteger.valueOf(2));
BigInteger zz=cal(y);
if(xx.multiply(xx).equals(n)==true) {
if(zz.multiply(zz).equals(y)==true)
System.out.println("Arena of Valor");
else System.out.println("Hearth Stone");
}
else {
if(zz.multiply(zz).equals(y)==true)
System.out.println("Clash Royale");
else System.out.println("League of Legends");
}
}
}
static BigInteger cal(BigInteger x) {
BigInteger ans=BigInteger.valueOf(0);
if(x.equals(BigInteger.valueOf(0))==true)return ans;
BigInteger r=BigInteger.valueOf(1);
BigInteger l=BigInteger.valueOf(-1);
while(true) {
BigInteger nxt =r.add(x.divide(r)).shiftRight(1);
if(nxt.equals(l)==true) {
if(l.compareTo(r)==-1)return r;
else return l;
}
l=r;r=nxt;
}
}
}