SGU111 Very simple problem
2013-08-12 12:35
239 查看
多少个平方数小于等于X,二分。
PS:java BigInteger。
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); } }
相关文章推荐
- Very simple problem - SGU 111(大数开方)
- SGU 111 Very simple problem
- SGU 111 Very simple problem 翻译 题解
- SGU 111 Very simple problem
- sgu 111 Very simple problem 高精开平方
- SGU111 Very simple problem
- SGU 111 Very simple problem
- SGU111 Very simple problem(大数开方)
- SGU 111 Very simple problem
- SGU 111 Very simple problem(高精度)
- SGU 111 Very simple problem(高精度+二分)
- 111. Very simple problem
- 数学/手开平方/sgu111 Very simple problem
- 111. Very simple problem
- A Very Simple Problem
- hdu 3483 A Very Simple Problem 矩阵
- sgu111:Very simple problem
- HUST 1563 - A Very Simple Problem
- FOJ 1350 Very Simple Problem
- foj 1350 Very Simple Problem