Input

The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output

For each number Ai from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.

Sample

input output
 1427  0   

   876652098643267843
5276538
2297.0716
936297014.1164
0.0000
37.7757

译文:

输入:

输入一个整数数组,这个数组中每个整数的取值范围为0<= Ai <=10的18次方。这些数字被一些空格和换行符分隔。输入的内存限制为256KB。

输出:

倒序输出数组的平方根。每个平方根结果保留最后四位小数。

==========================

第一次code:

 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.Scanner;

 public class Main
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);
         long[]a = new long[1000000000];
         int i;
         for (i=0; input.hasNext(); i++)
         {
              a[i] = input.nextLong();
         }
         for(i--;i>-1;i--)
         {
                         /**
                         *   Math.sqrt()  :  对数据求平方
                         *   BigDecimal适用于大型数据计算,精确度高
                         */
             BigDecimal   b   =   new   BigDecimal(Math.sqrt(a[i]));
             System.out.println(b.setScale(4,RoundingMode.HALF_UP).toString());
         }
     }
 }
     

-------------------------------------我是万恶的分割线---------------------------------------------------------------------------------------------------------

/*

题目稍微修改一下,首先输入一个数,定义数组大小,然后倒序输出该数组的平方根。

*/

 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.Scanner;

 public class Main
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);
         int n =input.nextInt();
         run();
     }
     public static void run()
     {
         Scanner input = new Scanner(System.in);
         long[]a = new long[n];
         int i;
         for (i=0; i<n; i++)
         {
              a[i] = input.nextLong();
         }
         for(i--;i>-1;i--)
         {
             BigDecimal   b   =   new   BigDecimal(Math.sqrt(a[i]));
             System.out.println(b.setScale(4,RoundingMode.HALF_UP).toString());
         }
     }
 }

Timus Online Judge 1001. Reverse Root的更多相关文章

  1. Ural 1001 - Reverse Root

    The problem is so easy, that the authors were lazy to write a statement for it! Input The input stre ...

  2. URAL 1001 Reverse Root(水题?)

    The problem is so easy, that the authors were lazy to write a statement for it! Input The input stre ...

  3. Timus Online Judge:ural:1006. Square Frames

    原题链接:http://acm.timus.ru/problem.aspx?space=1&num=1006 看到题第一反应:这玩意怎么读入…… 本地的话因为是全角字符,会占两个位置,所以需要 ...

  4. Timus Online Judge 1057. Amount of Degrees(数位dp)

    1057. Amount of Degrees Time limit: 1.0 second Memory limit: 64 MB Create a code to determine the am ...

  5. 数论ex

    数论ex 数学学得太差了补补知识点or复习 Miller-Rabin 和 Pollard Rho Miller-Rabin 前置知识: 费马小定理 \[ a^{p-1}\equiv 1\pmod p, ...

  6. Timus 1712. Cipher Grille 题解

    版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/.未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...

  7. [轉]Reverse a singly linked list

    Reverse a singly linked list  http://angelonotes.blogspot.tw/2011/08/reverse-singly-linked-list.html ...

  8. 项目cobbler+lamp+vsftp+nfs+数据实时同步(inotify+rsync)

    先配置好epel源 [root@node3 ~]#yum install epel-release -y 关闭防火墙和selinux [root@node3 ~]#iptables -F [root@ ...

  9. BZOJ1269——[AHOI2006]文本编辑器editor

    1.题意:各种splay操作,一道好的模板题2333 2.分析:splay模板题,没啥解释QAQ #include <stack> #include <cstdio> #inc ...

随机推荐

  1. How to implement a custom type for NHibernate property

    http://blog.miraclespain.com/archive/2008/Mar-18.html <?xml version="1.0" encoding=&quo ...

  2. WPF学习笔记——认识XAML

    Extensible Application Markup Language,XAML是一种声明性标记语言. 一.XAML语法概述 1,与XML类似,用尖括号标记元素 <StackPanel&g ...

  3. Win10/UWP新特性系列—Launcher实现应用间的通信

    UWP中,微软为Windows.System.Launcher启动器新增了很多的功能,以前只能启动App,打开指定扩展名文件,对uri协议的解析,以及当启动的应用没有安装时则会提示前往商店下载等. 如 ...

  4. UE4 VR 模式下全屏解决办法

    方法步骤: 1.打开关卡蓝图添加如下代码: 2.设置配置文件在工程目录里面找到 Config 文件夹在里面添加一个配置文件并命名为 DefaultGameUserSettings.ini 把如下内容贴 ...

  5. 数论 UVA 10780

    数论题目.有关内容:整数质因数分解,N的阶乘质因数分解,整除的判断. 这道题的题意是给你两个数n.m,要求你求出n!所能整除的m^k的最大值的k是多少. 由于数据范围:1<m<5000,1 ...

  6. strncpy基本用法

    见百度百科. 注意这句话: (c/c++)复制src中的内容(字符,数字.汉字....)到dest,复制多少由num的值决定,返回指向dest的指针.如果遇到null字符('\0'),且还没有到num ...

  7. postfix启动脚本

    使用该脚本是一定要注意postfix安装路径 #!/bin/bash # # postfix Postfix Mail Transger Agent # # chkconfig: # descript ...

  8. CE选择目录对话框(转)

    本文转载于http://blog.163.com/zhaojun_xf/blog/static/30050580201132221118479/ 在Wince下要打开目录对话框需要调用函数SHBrow ...

  9. lsm-tree

    https://www.quora.com/How-does-the-Log-Structured-Merge-Tree-work http://blog.cloudera.com/blog/2012 ...

  10. Redis 初

    tcl8.6.1 $wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz $tar xzvf tcl8.6.1-src.tar.g ...