题目链接:https://www.jisuanke.com/contest/1558/107313
吐槽: - - - - 队友牛X .. 全靠队友..... 这题 java 很恶心.
题意很明确: 判断 n 和 n*(n-1)/2 是否是完全平方数...
主要超时 在 判断完全平方...
代码:
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static BigInteger one = BigInteger.ONE;
public static BigInteger two = new BigInteger("2");
public static void init()
{
/*BigInteger p1 = new BigInteger("9");
BigInteger p2 = new BigInteger("289");
for(BigInteger n = p1 ; n.compareTo(new BigInteger("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"))<=0;)
{
n = BigInteger.valueOf(34).multiply(p1).subtract(p2).subtract(BigInteger.valueOf(16));
p2 = p1;
p1 = n;
System.out.println(n+",");
}*/
// BigInteger p1 = new BigInteger("2");
// BigInteger p2 = new BigInteger("289");
// for(BigInteger x = one; p1.compareTo(new BigInteger("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"))<=0;x=x.add(one)) {
// p1 = two.multiply(x.pow(2)).subtract(BigInteger.valueOf(20).multiply(x).add(two));
// p2 = one.subtract(x).multiply(one.subtract(BigInteger.valueOf(34).multiply(x)).add(x.pow(2)));
// p1 = p1.divide(p2);
// System.out.println(p1 + ",");
// }
}
public static void main(String[] args){
// init();
int T;
Scanner cin =new Scanner(System.in);
T = cin.nextInt();
while(T--!=0)
{
{
BigInteger n = cin.nextBigInteger();
BigInteger sumN = n.multiply(n.subtract(one)).shiftRight(1);
// System.out.println(sumN);
{
boolean f1 = is_square(n);
boolean f2 = is_square(sumN);
if (f1 == true && f2 == true) {
System.out.println("Arena of Valor");
} else if (f1 == false && f2 == false) {
System.out.println("League of Legends");
} else if (f1 == true && f2 == false) {
System.out.println("Hearth Stone");
} else if (f1 == false && f2 == true) {
System.out.println("Clash Royale");
}
}
}
}
}
public static boolean is_square(BigInteger n){
String a = n.toString();
if(n.toString().length()%2==0)
a = a.substring(0,n.toString().length()/2+1);
else
a = a.substring(0,(1+ n.toString().length())/2);
BigInteger x = new BigInteger(a);
BigInteger Two=new BigInteger("2");
if(a =="1")
{
x = one;
}else{
while(n.compareTo(x.multiply(x))<0){
x=(x.add(n.divide(x))).shiftLeft(1);
}
// System.out.println(x);
}
if(x.pow(2).compareTo(n) == 0)
return true;
else
return false;
}
}