Square root - UVa 10023 大数开方
来源:互联网 发布:网络曝光台吧 编辑:程序博客网 时间:2024/05/16 01:08
Square root
The Problem
You are to determinate X by given Y, from expression
The Input
The first line is the number of test cases, followed by a blank line.
Each test case of the input contains a positive integer Y (1<=Y<=101000), with no blanks or leading zeroes in it.
It is guaranteed, that for given Y, X will be always an integer.
Each test case will be separated by a single line.
The Output
For each test case, your program should print X in the same format as Y was given in input.
Print a blank line between the outputs for two consecutive test cases.
Sample Input
17206604678144
Sample Output
2684512
题意:大数开方。
思路:算作是一个模板收藏吧。
AC代码如下:
import java.math.BigInteger;import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner scan=new Scanner(System.in);BigInteger n,temp,y;BigInteger TWO=new BigInteger("2");int T,t,i,j,k;T=scan.nextInt();for(t=1;t<=T;t++){n=scan.nextBigInteger();y=n;do { temp = y; y = temp.add(n.divide(y)).divide(TWO); } while (y.compareTo(temp) == -1); if(t!=1) System.out.println();System.out.println(y);} }}
0 0
- UVa 10023 - Square root 大数开方
- Square root - UVa 10023 大数开方
- uva 10023 - Square root(手动开方)
- UVA 10023 Square root(高精度开方)
- UVA - 10023 - Square root (模拟手算开方)
- UVA 10023 Square root
- UVa 10023 - Square root
- UVa 10023 - Square root
- UVA 10023 Square root
- UVA - 10023 Square root
- UVa 10023 - Square root
- UVA 10023 - Square root(手算开根)
- uva 10494(大数加减乘除取余一条龙模板代码) uva 10023 (大数开方)
- 大数开方
- 大数开方
- 大数开方
- UVa 10023 Square root (高精度&开平方公式)
- UVA 10023 - Square root(手算平方根)
- flashback
- sphinx 使用教程-挺简单易懂
- PCL学习笔记(1):pcl1.6.0+vs2010环境配置以及第一个pcl程序
- 数据集网址
- java混合字符串中获取汉字部分
- Square root - UVa 10023 大数开方
- TCP/IP 详解卷一 - UDP
- Codeforces Round #290 (Div. 2) A,B,C,D
- oracle的ROWNUM
- 有情怀的格子布局(类似锤子桌面布局源码)
- SOAP UI 创建SOAP工程进行接口测试
- Graveyard
- 错排
- exit函数与return函数(c语言)