t组数据,每组输入n,判断n,n*(n-1)/2是否为完全平方数。
1.都是输出 A~o~V~
2.n是,n*(n-1)/2不是输出C~R~
3.n不是n*(n-1)/2是输出H~S~
4.否则 H~o~H~
java的很多方法
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class pool{
private static Scanner read;
public static void main(String[] args) {
read = new Scanner(System.in);
int t;
t=read.nextInt();
while(true) {
t--;
String s=read.next();
BigInteger x=new BigInteger(s);
BigInteger x1=new BigInteger("1");
BigInteger x2=new BigInteger("2");
BigInteger y=x.multiply(x.subtract(x1)).divide(x2);
BigInteger ans1=getSqrt(x.toString());
BigInteger ans2=getSqrt(y.toString());
int flag=0,flag1=0;
if((ans1.multiply(ans1)).compareTo(x)==0)flag=1;
if((ans2.multiply(ans2)).compareTo(y)==0)flag1=1;
if(flag==1&&flag1==1)System.out.println("Arena of Valor");
else if(flag==0&&flag1==1)System.out.println("Clash Royale");
else if(flag==1&&flag1==0)System.out.println("Hearth Stone");
else if(flag==0&&flag1==0)System.out.println("League of Legends");
if(t==0)break;
}
}
private static BigInteger getSqrt(String s) {
BigInteger remain=BigInteger.ZERO;
BigInteger odd=BigInteger.ZERO;
BigInteger ans=BigInteger.ZERO;
int group=0,k=0;
if(s.length()%2==1)
{
group=s.charAt(0)-'0';
k=-1;
}
else
{
group=(s.charAt(0)-'0')*10+s.charAt(1)-'0';
k=0;
}
for(int j=0;j<(s.length()+1)/2;j++)
{
if(j!=0)
group=(s.charAt(j*2+k)-'0')*10+s.charAt(j*2+k+1)-'0';
odd=BigInteger.valueOf(20).multiply(ans).add(BigInteger.ONE);
remain=BigInteger.valueOf(100).multiply(remain).add(BigInteger.valueOf(group));
int count=0;
while(remain.compareTo(odd)>=0)
{
count++;
remain=remain.subtract(odd);
odd=odd.add(BigInteger.valueOf(2));
}
ans=ans.multiply(BigInteger.TEN).add(BigInteger.valueOf(count));
}
return ans;
}
}