2018焦作网络赛J

Posted lmissher

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

 

以上是关于2018焦作网络赛J的主要内容,如果未能解决你的问题,请参考以下文章

2018焦作网络赛E

2018焦作网络赛B

2018焦作网络赛L

2018焦作网络赛K

2018焦作网络赛G

2018焦作网络赛A