SGU111 Very simple problem
多少个平方数小于等于X,二分。
PS:java BigInteger。
import java.util.*;
import java.math.*; public class Solution {
public static void main(String args[]) {
Scanner in = new Scanner(System.in); BigInteger X = in.nextBigInteger(); BigInteger L = BigInteger.valueOf(1);
BigInteger R = BigInteger.valueOf(10).pow(500); while (L.compareTo(R) <= 0) {
BigInteger M = L.add(R).divide(BigInteger.valueOf(2));
if (M.pow(2).compareTo(X) <= 0) {
L = M.add(BigInteger.valueOf(1));
} else {
R = M.subtract(BigInteger.valueOf(1));
}
} System.out.println(R);
}
}
SGU111 Very simple problem的更多相关文章
- POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)
A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...
- POJ 3468 A Simple Problem with Integers(线段树/区间更新)
题目链接: 传送门 A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Description Yo ...
- poj 3468:A Simple Problem with Integers(线段树,区间修改求和)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 58269 ...
- ACM: A Simple Problem with Integers 解题报告-线段树
A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%lld & %l ...
- poj3468 A Simple Problem with Integers (线段树区间最大值)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 92127 ...
- POJ3648 A Simple Problem with Integers(线段树之成段更新。入门题)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 53169 Acc ...
- BZOJ-3212 Pku3468 A Simple Problem with Integers 裸线段树区间维护查询
3212: Pku3468 A Simple Problem with Integers Time Limit: 1 Sec Memory Limit: 128 MB Submit: 1278 Sol ...
- POJ 3468 A Simple Problem with Integers(线段树区间更新区间查询)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 92632 ...
- A Simple Problem with Integers(树状数组HDU4267)
A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (J ...
随机推荐
- 写在十年 2007-09-15 (写给L之三)
你知道吗? 那种时间很远,但心很近的感觉. 时间已经远去了十年, 但亲切的感觉依然清晰可见, 无论时光远去了十年,二十年,三十年, 永远…… 它已经植根,在心间……
- AE实现投影定义和投影转换
添加引用ESRI.ArcGIS.DataManagementTools 1.获取要定义和要转换的投影 IWorkspaceFactory wsf = new ShapefileWorkspaceFac ...
- Linux multiple open a device
Linux multiple open a device a device = /dev/wiegand Linux在多次打开同一个设备(/dev/wiegand)的时候,打开结果都是成功,但是在用w ...
- C++与Lua交互(一)
引言 之前做手游项目时,客户端用lua做脚本,基本所有游戏逻辑都用它完成,玩起来有点不爽,感觉"太重"了.而我又比较偏服务端这边(仅有C++),所以热情不高.最近,加入了一个端游项 ...
- C语言 SDK编程之通用控件的使用--ListView
一.ListView控件属于通用控件CONTROL中的一种,在SDK编程方式时要使用通用控件 必须包含comctl32.dll,所以代码中要有头文件: commctrl.h 导入库:comctl32. ...
- L005-oldboy-mysql-dba-lesson05
L005-oldboy-mysql-dba-lesson05 在线改表工具:pt-onine-schema-change 来自为知笔记(Wiz)
- hash桶
#include <stdio.h> #include <stdlib.h> #include "chain.c" //include the chain. ...
- linux 安装mysql 5.7.16
http://blog.csdn.net/huangliang0703/article/details/49935775
- Mysql MyISAM数据库批量转换表引擎为Innodb
Mysql MyISAM数据库批量转换表引擎为Innodb 最近在做事物处理需要把表结构都改为带有支持事物的Innodb引擎格式, 把里面数据库 用户名.密码 等信息修改为你自己的,放在网站下运行即可 ...
- CentOS 安装jdk1.7 64位
[root@localhost ~]# java -versionjava version "1.6.0"OpenJDK Runtime Environment (build 1. ...