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. vs2012 vs2010 opencv2.4.7配置

    http://blog.csdn.net/xiaohanstu/article/details/45309149?utm_source=tuicool <pre name=.7配置 .配置 () ...

  2. Android Sudoku第一版

    经过几天的下班空闲时间写了一个android上的数独游戏,今天也申请了几个发布平台的账号,发布出去了,google play要收25刀,而且这个在大陆基本访问不上,所以暂时就没买.在移动平台写应用程序 ...

  3. C++ Daily 《3》----构造函数可否是虚函数

    C++ 中构造函数可否是虚函数? 绝不要!! 而且,在构造函数中调用虚函数也是不提倡的行为,因为会引发预想不到的结果. 因为,在 derived class 对象构造的过程中,首先调用的是基类的构造函 ...

  4. C语言之共用体

    最近在复习C语言,特再次记录: 有时需要将几种不同类型的变量存放到同一段内存单元中.如一个int.float.char放在同一个地址开始的内存单元中.,也就是使用覆盖技术,几个变量相互覆盖,称之为共用 ...

  5. php轮流排序,每隔一定的时间轮流进行位置排序,轮询的排行榜:function dataPollingInterval()

    /* * @名称: php ,对数组每隔一定的时间(自设定时间)来轮流进行位置排序,轮询的排行榜. 精确到指定的秒 或 分钟 或 小时 或 天 ,对数据列表进行轮排. * @参数: (array)$l ...

  6. Eos持久化实体

    持久化实体 2009-11-30 20:53:38|  分类: 记事本_学习笔记 |  标签: |举报 |字号大中小 订阅     在EOS的实体定义中,如果使用了关联实体方式,主实体的外键属性是不存 ...

  7. 数据库基础知识(1)--数据库php连接

    关系数据库的常用基本术语  数据data 数据库database 数据库管理系统dbms 表(数据表)table 字段field,列column 行row,记录record 数据库操作的基本模式(流程 ...

  8. MYSQL分库分表和不停机更改表结构

    在MYSQL分库分表中我们一般是基于数据量比较大的时间对mysql数据库一种优化的做法,下面我简单的介绍一下mysql分表与分库的简单做法. .分库分表 很明显,一个主表(也就是很重要的表,例如用户表 ...

  9. C#调用C++ DLL类方法

    C++的优势在于高效灵活,C#的优势在于简单易用,两者结合起来对项目开发来说是件好事,而且C++不容易反编译,也保障了代码的安全性,如果一些核心算法使用C#编写,那么保密就是一个问题. C++生成的D ...

  10. supervisor使用详解

    1.什么是supervisorsupervisor是用python写的一个进程管理工具,用来启动,重启,关闭进程. 2.supervisor的安装 pip install supervisor 3.s ...