111.Very simple problem

time limit per test: 0.5 sec. 
memory limit per test: 4096 KB

You are given natural number X. Find such maximum integer number that it square is not greater than X.

Input

Input file contains number X (1≤X≤101000).

Output

Write answer in output file.

Sample Input

16

Sample Output

4

开平方的方法懒得写,索性二分,可能的话将来回来写写

实际用时:11min

import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner; public class Main {
public static void main(String []args) throws IOException{
BigInteger X;
Scanner scanner=new Scanner(System.in);
X=scanner.nextBigInteger();
if(X.compareTo(BigInteger.ONE)==0){
System.out.println("1");
return ;
}
BigInteger l=BigInteger.ZERO,r=X;
while(r.compareTo(l.add(BigInteger.ONE))==1){
BigInteger mid=l.add(r).shiftRight(1);
int fl=X.compareTo(mid.multiply(mid));
if(fl==0){
l=mid;
break;
}
else if(fl==-1){
r=mid;
}
else {
l=mid;
}
}
System.out.println(l);
}
}

  

快速切题 sgu 111.Very simple problem 大数 开平方 难度:0 非java:1的更多相关文章

  1. 快速切题 sgu 112. a^b-b^a 大数 次方 难度:0 非java:1

    112. a^b-b^a time limit per test: 0.25 sec. memory limit per test: 4096 KB You are given natural num ...

  2. SGU 111.Very simple problem

    题目大意:              求平方不大于n(n<=10^1000)的最大的数. 分析:              二分+高精度乘法 或者 高精度开方...               ...

  3. 快速切题 sgu102.Coprimes 欧拉函数 模板程度 难度:0

    102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB For given integer N (1&l ...

  4. 快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0

    487-3279 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 247781   Accepted: 44015 Descr ...

  5. SGU 144. Meeting 概率dp 几何概率分布 难度:0

    144. Meeting time limit per test: 0.25 sec. memory limit per test: 4096 KB Two of the three members ...

  6. hdu_3483A Very Simple Problem(C(m,n)+快速幂矩阵)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3483 A Very Simple Problem Time Limit: 4000/2000 MS ( ...

  7. hdu3483 A Very Simple Problem 非线性递推方程2 矩阵快速幂

    题目传送门 题目描述:给出n,x,mod.求s[n]. s[n]=s[n-1]+(x^n)*(n^x)%mod; 思路:这道题是hdu5950的进阶版.大家可以看这篇博客hdu5950题解. 由于n很 ...

  8. A Very Simple Problem

    A Very Simple Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...

  9. A simple problem 分类: 哈希 HDU 2015-08-06 08:06 1人阅读 评论(0) 收藏

    A simple problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...

随机推荐

  1. VC中GetLastError()获取错误信息的使用,以及错误代码的含义

    转载:http://www.seacha.com/article.php/knowledge/windows/mfc/2011/0423/335.html VC中GetLastError()获取错误信 ...

  2. SRLTE,SGLTE,SVLTE,CSFB,VoLTE的区别【转】

    本文转载自:https://blog.csdn.net/dangbochang/article/details/43851979 SRLTE——Single Radio LTE,俗称单待LTE. SG ...

  3. C语言宏定义中的#和##的作用【转】

    本文转载自:http://my.oschina.net/shelllife/blog/123202 在宏定义中#和##的作用是:前者将宏定义的变量转化为字符串:后者将其前后的两个宏定义中的两个变量无缝 ...

  4. c++类定义代码的分离

    类文件 实际工程中,对一个类的说明.架构.描述方法是:    往往分成头文件和实现的源文件,来实现代码的分离 然后,源文件中包含类的头文件... 头文件的包含问题: 类对应的实现文件cpp.main主 ...

  5. IDEA启动时自动报Plugin Error错误

    Plugin Error Problems found loading plugins: Plugin "JBoss Integration" was not loaded: re ...

  6. apiCloud检出代码出现以下图示错误:

    问题如下: Initialized empty Git repository in H:/simlpe/.git/ 已经在 H:\simlpe 完成必要的项目初始化工作正在尝试从代码服务器获取数据.. ...

  7. HDU 3065 病毒侵袭持续中(AC自动机(每个模式串出现次数))

    http://acm.hdu.edu.cn/showproblem.php?pid=3065 题意:求每个模式串出现的次数. 思路: 不难,把模板修改一下即可. #include<iostrea ...

  8. UVa 820 因特网带宽(最大流)

    https://vjudge.net/problem/UVA-820 题意: 给出所有计算机之间的路径和路径容量后求出两个给定结点之间的流通总容量. 思路: 裸的最大流问题.注意有个比较坑的地方,最后 ...

  9. 正则表达式及R字符串处理之终结版

    http://yphuang.github.io/blog/2016/03/15/regular-expression-and-strings-processing-in-R/ 0.动机:为什么学习字 ...

  10. 51nod 1042 数字0-9的数量 数位dp

    1042 数字0-9的数量 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题  收藏  关注 给出一段区间a-b,统计这个区间内0-9出现的次数.   比如 10-1 ...