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;

    }
}

原文地址:https://www.cnblogs.com/LMissher/p/9655129.html

时间: 2024-09-30 07:10:45

2018焦作网络赛J的相关文章

2018 徐州网络赛 J

131072K After the long vacation, the maze designer master has to do his job. A tour company gives him a map which is a rectangle. The map consists of N \times MN×M little squares. That is to say, the height of the rectangle is NN and the width of the

2018沈阳网络赛J

给一颗树,两种操作,一种把同一层的点权值加上v,另一种求一点下的子树权值和. 按层数中点个数分块,小块直接暴力把所有点用bit更新,大块把层的值存下来. 询问的时候子树权值和为bit中的值以及其下面的点在大块中的值,下面中的点在大块中的值用二分实现. #include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #define pb push_back #define mp make

2018焦作网络赛B

dp维护一下最大值与最小值,注意边界情况的判定. #include <iostream> #include <cstring> using namespace std; const long long inf = (long long)1e18+(long long)9; long long dp[7][1005]; long long dpx[7][1005]; int f[1005]; char s[15]; int main() { int T; // int l; int

2018焦作网络赛 - Poor God Water 一道水题的教训

本题算是签到题,但由于赛中花费了过多的时间去滴吧格,造成了不必要的浪费以及智商掉线,所以有必要记录一下 题意:方格从1到n,每一格mjl可以选择吃鱼/巧克力/鸡腿,求走到n格时满足 1.每三格不可重复同一种食物 2.每三格均不同食物时中间格子不可吃巧克力 3.每三格前后两格不可同时吃巧克力 以上三个条件的方案数,n<1e10 太长不看版:打表+快速幂AC 长篇吐槽版 很显然的,设\(dp[n][i][j][k]\),走到第\(n\)格时第\(n-2\)格的食物是\(i\),第\(n-1\)的食物

ICPC 2018 南京网络赛 J Magical Girl Haze(多层图最短路)

传送门:https://nanti.jisuanke.com/t/A1958 题意:n个点m条边的路,你有k次机会将某条路上的边权变为0,问你最短路径长度 题解:最短路变形,我们需要在常规的最短路上多开 一维,记录,我消耗j次机会时的最短路径长度为多少 代码: /** * ┏┓ ┏┓ * ┏┛┗━━━━━━━┛┗━━━┓ * ┃ ┃ * ┃ ━ ┃ * ┃ > < ┃ * ┃ ┃ * ┃... ⌒ ... ┃ * ┃ ┃ * ┗━┓ ┏━┛ * ┃ ┃ Code is far away fro

2018焦作网络赛B-Mathematical Curse

B: Mathematical Curse 时间限制: 1 Sec  内存限制: 128 MB 题目描述 A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reach

2018焦作网络赛E

区间更新加法与乘法,x取反是2^64-x-1,由于取模所以取反变成-x-1,就区间+1再*-1就可以了,最后区间询问求和. 待补 原文地址:https://www.cnblogs.com/LMissher/p/9655105.html

2018焦作网络赛-E- Jiu Yuan Wants to Eat

题目描述 You ye Jiu yuan is the daughter of the Great GOD Emancipator.  And when she becomes an adult, she will be queen of Tusikur, so she wanted to travel the world while she was still young. In a country, she found a small pub called Whitehouse. Just

2018焦作网络赛G-Give Candies

G: Give Candies 时间限制: 1 Sec  内存限制: 128 MB 题目描述 There are N children in kindergarten. Miss Li bought them N candies.To make the process more interesting, Miss Li comes up with the rule: All the children line up according to their student number (1…N),