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. CCF WC2017 & THU WC2017 旅游记

    day-x 真·旅游 去了杭州的一些景点,打了几场练习赛. day0 报到日 领资料.入住,中午在食堂吃饭,感觉做的挺好的,和二高食堂差不多.晚上还有开幕式. day1~day4 白天讲课,晚上营员交 ...

  2. NORMA2 - Norma [cdq分治]

    题面 洛谷 你有一个长度为n的序列,定义这个序列中每个区间的价值是 \(Cost(i,j)=Min(Ai...Aj)∗Max(Ai...Aj)∗(j−i+1)Cost(i,j)=Min(A_{i}.. ...

  3. Centos7安装OpenDCIM-19.01步骤

    Centos7安装OpenDCIM-19.01步骤 openDCIM是一款免费的开源解决方案,用于管理数据中心基础设施.它已经被几家企业组织所使用,由于开发人员的不懈努力,正在迅速完善. openDC ...

  4. android startActivityForResult 使用实例

    ActivityForResult.java public class ActivityForResult extends Activity { Button bn; EditText city; @ ...

  5. Codeforces | CF1010C 【Border】

    这道题大致题意是给定\(n\)个十进制整数和一个进制数\(k\),可以用无数多个给定的十进制整数,问这些十进制整数的和在模k意义下有多少种不同的结果(\(k\)进制下整数的最后一位就是这个数模\(k\ ...

  6. Centos 7下下载和安装docker

    sudo yum install -y device-mapper sudo modprobe dm_mod ls -l /sys/class/misc/device-mapper sudo rpm ...

  7. redux源码解析-redux的架构

    redux很小的一个框架,是从flux演变过来的,尽管只有775行,但是它的功能很重要.react要应用于生成环境必须要用flux或者redux,redux是flux的进化产物,优于flux. 而且r ...

  8. javascript的性能优化tips

    谈到javascript的性能优化,有好多点,比如把script放到离body闭合标签附近,合并多个script标签等等,还有一些代码的性能,for的性能不如while的性能好,用while模拟for ...

  9. js 判断所选时间(或者当前时间)是否在某一时间段的实现代码

    var time_range = function (beginTime, endTime, nowTime) { var strb = beginTime.split (":") ...

  10. jokes

    先看效果如下 目录如下 //index.html <!DOCTYPE html> <html lang="zh-CN"> <head> < ...