2018焦作网络赛J

不知道题意,队友用java大数+二分过了?

 

 

 

import java.util.Arrays;
import java.util.Scanner;

import java.io.*;
import java.math.*;
public class Main {
    static boolean check(BigInteger num,BigInteger n) {
        boolean flag = true;
        BigInteger a = new BigInteger("0");
        BigInteger cnt = new BigInteger("16");
        BigInteger B1 = new BigInteger("1");
        BigInteger B2 = new BigInteger("2");
        BigInteger B3 = new BigInteger("3");
        BigInteger B4 = new BigInteger("4");
        BigInteger B5 = new BigInteger("5");
        BigInteger B6 = new BigInteger("6");
        BigInteger B7 = new BigInteger("7");
        BigInteger B8 = new BigInteger("8");
        BigInteger B9 = new BigInteger("9");

        if(num.compareTo(B2) == 0 || num.compareTo(B3) == 0 || num.compareTo(B7) == 0 || num.compareTo(B8) == 0) {
            return false;
        } else {
            num = n.mod(cnt);
            if(num.compareTo(BigInteger.ZERO) != 0 && num.compareTo(B1) != 0 && num.compareTo(B4) != 0 && num.compareTo(B9) != 0) {
                return false;
            } else {
                a = sqrt(n);
            }
        }
        if(a.multiply(a).compareTo(n) != 0) {
            return false;
        }
        return true;


    }
    //public static void main(String [] args) throws FileNotFoundException {
        //File file = new File("J.in");
        //InputStream in = new BufferedInputStream(new FileInputStream(file));
        //System.setIn(in);
        public static void main(String [] args) {

        BigInteger B1 = new BigInteger("1");
        BigInteger B2 = new BigInteger("2");
        BigInteger B3 = new BigInteger("3");
        BigInteger B4 = new BigInteger("4");
        BigInteger B5 = new BigInteger("5");
        BigInteger B6 = new BigInteger("6");
        BigInteger B7 = new BigInteger("7");
        BigInteger B8 = new BigInteger("8");
        BigInteger B9 = new BigInteger("9");

        Scanner cin = new Scanner(System.in);
        BigInteger n = new BigInteger("0");
        int t;
        t = cin.nextInt();
        while(t > 0) {
            t--;
            boolean flag1 = true, flag2 = true;
            n = cin.nextBigInteger();
            BigInteger m = n.multiply(n.subtract(B1));
            m = m.divide(B2);
            flag1 = check(n.mod(BigInteger.TEN),n);
            flag2 = check(m.mod(BigInteger.TEN),m);
            
            if(flag1 && flag2) {
                System.out.println("Arena of Valor");
            } else if(flag1&& !flag2 ) {
                System.out.println("Hearth Stone");
            } else if(!flag1&& flag2) {
                System.out.println("Clash Royale");
            } else {
                System.out.println("League of Legends");
            }
        }

    }
    static BigInteger sqrt(BigInteger x) {
        BigInteger now = BigInteger.ZERO ;
        BigInteger l = BigInteger.ONE ;
        BigInteger r = x ;
        while(l.equals(r) == false) {
            BigInteger mid = (l.add(r)).divide(BigInteger.valueOf(2)) ;
            if(now.compareTo(BigInteger.ZERO) != 0 && now.compareTo(mid) == 0) {
                break ;
            } else {
                now = mid ;
            }
            if(now.compareTo(BigInteger.ZERO) == 0) {
                now = mid ;
            }
            if(mid.multiply(mid).compareTo(x) == 1) {
                r=mid ;
            } else {
                l=mid ;
            }
        }
        if(l.multiply(l).compareTo(x) == 1) {
            l=l.subtract(BigInteger.ONE) ;
        }
        return l;

    }
}
View Code

 

posted @ 2018-09-16 09:39  LMissher  阅读(192)  评论(0编辑  收藏  举报