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

 

转载于:https://www.cnblogs.com/LMissher/p/9655129.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值