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. RSA非对称加密

    先上RSA加密算法的一些简介(截图自轩辕老师的课件): 嗯--RSA就是这么一回事,于是有了如下题目: 1.In an RSA system, the public key of a given us ...

  2. Windows 托盘区域显示图标

    NOTIFYICONDATA structure 这个结构体包含了向通知区域(底部任务栏右下角区域,下面都称为托盘)显示的信息.需要使用函数Shell_NotifyIcon. 结构体成员 typede ...

  3. 启动运行下载gradle速度太慢,手动添加

    启动运行下载gradle速度太慢,并且容易卡死(感谢群友ˋ狠ㄨ得意提供支持)---国内网络访问地址 我们经常运行项目的时候会需要进行下载gradle,不过由于网络或者和谐的问题经常下载需要花很长时间或 ...

  4. 使用样式“clear”和“overflow”消除浮动元素对环绕行框的影响

    为元素设置“float”样式之后,元素会脱离标准文档流,不再占据原来的空间.后续元素会向前移动,占据这个新的空间.后续的文本会围绕着浮动元素分布,形成一种环绕布局的现象. 示例代码: <!DOC ...

  5. CSS样式“display:none”与“visibility:hidden”区别

    CSS样式“display:none”和“visibility:hidden”都可以实现将页面元素隐藏,但是具体的效果是有差别的!下面通过两个小实验来说明这种差异. 实验代码: <!DOCTYP ...

  6. crontabs Permission denied

    问题 jack@somemachine /data/jack $ crontab -e crontabs/jack: Permission denied 解决办法 sudo chown root:cr ...

  7. protobuf 数据解析的2种方法

    方法1: message person{required int32 age = 1;required int32 userid = 2;optional string name = 3;} mess ...

  8. 盯盯拍Android App 3.0指导

    http://www.ddpai.com/bbs/thread-233-1-1.html 视频介绍:http://v.17173.com/v_102_604/MzA0OTAwMDg.html

  9. 关于windows字体的一些笔记

    windows如何管理字体 windows的字体管理在注册表的windows/font这部分(具体路径忘记了),这里会记录字体的名称和名称,如果有具体指出路径,windows启动的时候会从这个路径去加 ...

  10. Oracle数据库的后备和恢复————关于检查点的一些知识

    当我们使用一个数据库时,总希望数据库的内容是可靠的.正确的,但由于计算机系统的故障(硬件故障.软件故障.网络故障.进程故障和系统故障)影响数据库系统的操作,影响数据库中数据的正确性,甚至破坏数据库,使 ...