https://nanti.jisuanke.com/t/31719

题意

让你分别判断n或(n-1)*n/2是否是完全平方数

分析

二分高精度开根裸题呀。经典题:bzoj1213

用java套个板子求出平方根,再乘回来检验一下就好。

import java.util.*;
import java.math.*;
public class Main{
static BigInteger check(BigInteger n,BigInteger x) {
BigInteger ans=BigInteger.valueOf();
BigInteger a=BigInteger.valueOf();
for(BigInteger i=BigInteger.ZERO;i.compareTo(n)<;i=i.add(a)) {
ans=ans.multiply(x);
}
return ans;
}
static BigInteger Get(BigInteger n,BigInteger m) {//大数m开n次根
BigInteger l=BigInteger.ZERO;
BigInteger a=BigInteger.valueOf();
BigInteger b=BigInteger.valueOf();
BigInteger r=BigInteger.valueOf();
BigInteger mid=BigInteger.ZERO;
while(check(n,r).compareTo(m)<=) {
l=r;
r=r.multiply(a);
}
while(l.compareTo(r)<=) {
mid=l.add(r).divide(a);
if(check(n,mid).compareTo(m)<=) l=mid.add(b);
else r=mid.subtract(b);
}
return r;
}
public static void main(String[]args) {
int t;
Scanner sca=new Scanner(System.in);
t=sca.nextInt();
BigInteger m=new BigInteger("");
while(t--!=){
BigInteger n1=sca.nextBigInteger();
BigInteger n2=n1.multiply(n1.subtract(BigInteger.ONE)).divide(m);
BigInteger res1=Get(m,n1);
BigInteger res2=Get(m,n2);
boolean f1=false,f2=false;
if(res1.multiply(res1).compareTo(n1)==) f1=true;
if(res2.multiply(res2).compareTo(n2)==) f2=true;
if(f1&&f2){
System.out.println("Arena of Valor");
}else if(f1){
System.out.println("Hearth Stone");
}else if(f2){
System.out.println("Clash Royale");
}else{
System.out.println("League of Legends");
} }
}
}

ACM-ICPC 2018 焦作赛区网络预赛 J Participate in E-sports(大数开方)的更多相关文章

  1. 大数开方 ACM-ICPC 2018 焦作赛区网络预赛 J. Participate in E-sports

    Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know ...

  2. ACM-ICPC 2018 焦作赛区网络预赛J题 Participate in E-sports

    Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know ...

  3. ACM-ICPC 2018 焦作赛区网络预赛- L:Poor God Water(BM模板/矩阵快速幂)

    God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him t ...

  4. ACM-ICPC 2018 焦作赛区网络预赛

    这场打得还是比较爽的,但是队友差一点就再过一题,还是难受啊. 每天都有新的难过 A. Magic Mirror Jessie has a magic mirror. Every morning she ...

  5. ACM-ICPC 2018 焦作赛区网络预赛 K题 Transport Ship

    There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry th ...

  6. ACM-ICPC 2018 焦作赛区网络预赛 L 题 Poor God Water

    God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him t ...

  7. ACM-ICPC 2018 焦作赛区网络预赛 G题 Give Candies

    There are NN children in kindergarten. Miss Li bought them NN candies. To make the process more inte ...

  8. ACM-ICPC 2018 焦作赛区网络预赛 B题 Mathematical Curse

    A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics ...

  9. ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer (最大生成树+LCA求节点距离)

    ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer J. Maze Designer After the long vacation, the maze designer ...

随机推荐

  1. 【BZOJ4042】【CERC2014】parades 状压DP

    题目大意 给你一棵\(n\)个点的树和\(m\)条路径要求你找出最多的路径,使得这些路径不共边.特别的,每个点的度数\(\leq 10\). \(n\leq 1000,m\leq \frac{n(n- ...

  2. python的生成器与迭代器和可迭代对象

    来简单的说下python中的生成器和可迭代对象以及迭代器的问题.只是简单地记录一下并不涉及太深入的内容. 首先来说一下什么是生成器,先看下面的代码: #_*_ coding:utf-8 _*_ res ...

  3. [国家集训队]整数的lqp拆分

    我们的目标是求$\sum\prod_{i=1}^m F_{a_i}$ 设$f(i) = \sum\prod_{j=1}^i F_{a_j}$那么$f(i - 1) = \sum\prod_{j=1}^ ...

  4. WC2019 tree

    WC2019唯一一道正常的题,考场上没什么想法,也只拿到了暴力分.搞了一天终于做完了. 前置知识:purfer序,多项式exp或分治FTT. 对于\(type=0\)的,随便维护下,算下联通块即可. ...

  5. NOIP2018退役记(记事)

    希望还是要有的,万一退役了呢? Day1 听说300是大众分? 不会T2,不会T3,再别OI. Day2 听说200是大众分? T1FST掉,不会T2,不会T3,再别OI. 茶馆小人书 那些让我们聊以 ...

  6. Hdoj 1879.继续畅通工程 题解

    Problem Description 省政府"畅通工程"的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可).现得到城镇道路统计 ...

  7. Java List 遍历

    //方法1 Iterator it1 = list.iterator(); while(it1.hasNext()){ System.out.println(it1.next()); } //方法2 ...

  8. 牛客寒假算法基础集训营3B 处女座的比赛资格(用拓扑排序解决DAG中的最短路)

    链接:https://ac.nowcoder.com/acm/contest/329/B 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言5242 ...

  9. 牛客练习赛28 B数据结构(线段树)

    链接:https://www.nowcoder.com/acm/contest/200/B来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言5242 ...

  10. VSCode and NoteBook for JavaScript | NodeJS

    VSCode调试HTML环境配置 | Jupyter NoteBook IJavaScript 配置 VSCode调试HTML环境配置 先安装两个插件:Debugger for Chrome(调试) ...