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. Mac安装和卸载HomeBrew

    安装方法: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/ ...

  2. 三点估算和PERT技术

    三点估算是PMP考试中的必考题目,每次约2-4道题目.现在就三点估算和PERT技术做详细讲解,以飨读者. 通过考虑估算中的不确定性和风险,可以提高活动持续时间估算的准确性.这个概念起源于计划评审技术( ...

  3. win7下把电脑设置成wlan热

    有很多公司没有无线网,只有自己的电脑可以上网,现在设置热点,可以手机上网 步骤: 1.看自己的网卡是否支持承载网络,如果不支持,本法就不适用 在CMD里用    netsh wlan show dri ...

  4. Win7系统中如何查看当前文件被哪一个程序占用了

    https://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows ...

  5. 【第二十五章】 springboot + hystrixdashboard

    注意: hystrix基本使用:第十九章 springboot + hystrix(1) hystrix计数原理:附6 hystrix metrics and monitor 一.hystrixdas ...

  6. spring boot 修改Tomcat端口

    package com.tsou.Controller; import org.springframework.boot.*; import org.springframework.boot.auto ...

  7. web.xml配置文件详细解读

    对于一个J2EE应用的开发者,或者叫java web后台的开发者来说.经常会和web.xml打交道,偶尔用到几个标签不知道啥意思.然后就度娘一下,久而久之虽然大概知道web.xml的基本使用方法,但是 ...

  8. 【hbuilder】如何根据Geolocation获得的坐标获取所在城市?

    第一步通过mui.plusReady[表示页面加载事件]调用hbuilder提供的百度定位 mui.plusReady(function() { plus.geolocation.getCurrent ...

  9. Java8 新特性之默认接口方法

    摘要: 从java8开始,接口不只是一个只能声明方法的地方,我们还可以在声明方法时,给方法一个默认的实现,我们称之为默认接口方法,这样所有实现该接口的子类都可以持有该方法的默认实现. · 待定 一. ...

  10. a 样式重置 常见用法

    样式重置 a:link, a:visited, a:hover, a:active{   color: #fff;   text-decoration: none; }   常见用法  ( rel=& ...