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. DNSCrypt

    DNSCrypt 来源 https://www.cnblogs.com/qiudabai/articles/9219840.html https://www.opendns.com/about/inn ...

  2. nginx 重定向 说明

    一.nginx 两个操作系统的安装见以前的随笔(已安装请跳过) linux上搭建nginx windows上搭建nginx 二.Nginx重定向——直接到项目,而非nginx欢迎页 默认ngin修改n ...

  3. RequestContextHolder 很方便的获取 request

    在 Spring boot web 中我们可以通过 RequestContextHolder 很方便的获取 request. ServletRequestAttributes requestAttri ...

  4. Hdoj 2717.Catch That Cow 题解

    Problem Description Farmer John has been informed of the location of a fugitive cow and wants to cat ...

  5. [HNOI2015]落忆枫音 解题报告

    [HNOI2015]落忆枫音 设每个点入度是\(d_i\),如果不加边,答案是 \[ \prod_{i=2}^nd_i \] 意思是我们给每个点选一个父亲 然后我们加了一条边,最后如果还这么统计,那么 ...

  6. 理解Spark的核心RDD

    http://www.infoq.com/cn/articles/spark-core-rdd/

  7. Star sky CodeForces - 835C

    用一个三维数组cnt[x][y][k]表示从(1, 1)到(x, y)亮度为k的个数,然后查询的时候就是对于每一个亮度,计算出这个亮度t秒后的亮度和当前这个亮度的个数,答案就是他们的乘积, 然后遍历每 ...

  8. POJ1061 青蛙的约会(扩展欧几里得)

    题目链接:http://poj.org/problem?id=1061 青蛙的约会 Time Limit: 1000MS   Memory Limit: 10000K Total Submission ...

  9. (三)flask中的请求钩子函数

    请求勾子 在客户端和服务器交互的过程中,有些准备工作或扫尾工作需要处理,比如: 在请求开始时,建立数据库连接: 在请求开始时,根据需求进行权限校验: 在请求结束时,指定数据的交互格式: 为了让每个视图 ...

  10. eureka集群基于DNS配置方式

    https://www.cnblogs.com/relinson/p/eureka_ha_use_dns.html   最近在研究spring cloud eureka集群配置的时候碰到问题:多台eu ...