ACM-ICPC 2018 焦作赛区网络预赛 J Participate in E-sports(大数开方)
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(大数开方)的更多相关文章
- 大数开方 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 ...
- 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 ...
- 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 ...
- ACM-ICPC 2018 焦作赛区网络预赛
这场打得还是比较爽的,但是队友差一点就再过一题,还是难受啊. 每天都有新的难过 A. Magic Mirror Jessie has a magic mirror. Every morning she ...
- 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 ...
- 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 ...
- ACM-ICPC 2018 焦作赛区网络预赛 G题 Give Candies
There are NN children in kindergarten. Miss Li bought them NN candies. To make the process more inte ...
- ACM-ICPC 2018 焦作赛区网络预赛 B题 Mathematical Curse
A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics ...
- ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer (最大生成树+LCA求节点距离)
ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer J. Maze Designer After the long vacation, the maze designer ...
随机推荐
- 我的代码库-Java8实现FTP与SFTP文件上传下载
有网上的代码,也有自己的理解,代码备份 一般连接windows服务器使用FTP,连接linux服务器使用SFTP.linux都是通过SFTP上传文件,不需要额外安装,非要使用FTP的话,还得安装FTP ...
- python活用isdigit方法显示系统进程
如何利用字符串的内置函数isdigit(),判断一个字符串是一个纯数字.如果是纯数字会返回True,否则返回fasle. 利用isdigit()方法编写一个python脚本显示所有系统进程pid.os ...
- 【LOJ#6029】市场(线段树)
[LOJ#6029]市场(线段树) 题面 LOJ 题解 看着就是一个需要势能分析的线段树. 不难发现就是把第二个整除操作化为减法. 考虑一下什么时候整除操作才能变成减法. 假设两个数为\(a,b\). ...
- Dynamic CRM 2015学习笔记(3)oData 查询方法及GUID值比较
本文将比较二种查询字符串在同一个oData查询方法中的不同,另外,还将介绍如何比较不同方法返回的GUID的值. 用同一个oData查询方法,如果传入查询的字符串不一样,返回结果的格式竟然完全不一样. ...
- hexo+next主题目录解析
默认目录结构: . ├── .deploy ├── public ├── scaffolds ├── scripts ├── source | ├── _drafts | └── _posts ├── ...
- prufer序列学习笔记
prufer序列是一个定义在无根树上的东西. 构造方法是:每次选一个编号最小的叶子结点,把他的父亲的编号加入到序列的最后.然后删掉这个叶节点.直到最后只剩下两个节点,此时得到的序列就是prufer序列 ...
- TYVJ1266 费解的开关
恩,这题...... 看看题面想到了啥?炮兵阵地! 再仔细一思考:炮兵阵地是求放置最多,而这个显然可以递推得出. 由于每个格子至多点一次,那么我们发现: 在第一行点击状态确定的情况下,后面每个格子的点 ...
- python(一)——初识与变量
---恢复内容开始--- #!/usr/bin/env python #-*- coding:utf8 -*- print('你好hello world') 第一行,主要用于Linux中环境变量,wi ...
- margin纵向重叠
速记: 如p的纵向 margin 是 16px,那么两个之间纵向的距离是多少?-- 按常理来说应该是 16 + 16 = 32px,但是答案仍然是 16px. 因为纵向的 margin 是会重叠的,如 ...
- 在views中引用UserProfile报错RuntimeError: Model class apps.users.models.UserProfile doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
如图报错,在settings中,该加的也加了啊! 显然类似于网上最容易遇到的解决方案如下图,是没有任何意义的 只要在view中有 from .models import UserProfile,Ver ...