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. windows核心编程---第三章 内核对象及句柄本质

      本章讨论的是相对抽象的概念,不涉及任何具体的内核对象的细节而是讨论所有内核对象的共有特性. 首先让我们来了解一下什么是内核对象.内核对象通过API来创建,每个内核对象是一个数据结构,它对应一块内存 ...

  2. linux命令:less

    1.命令介绍: less用来逐页输出文件内容,less相比more功能更加强大,less可以前后翻页,前后搜索. 2.命令格式: less [选项] 文件 3.命令参数: -b <缓冲区大小&g ...

  3. Win10/UWP新特性系列—电池报告

    UWP中,新增了当节电模式开启时,App能获取到通知的API,通过响应电源条件的更改,比如咨询用户是否使用黑色背景等来帮助延长电池使用时间. 通过Windows.Devices.Power命名空间中的 ...

  4. C++ 调用 java jni.h 的使用

    JNI c++ 调用 java ----------------------------------------------c++----------------------------------- ...

  5. RBL开发笔记二

     17:13:55 2014-08-25 有以下几个点:  第一 :怎么在预处理阶段能够做到识别某个宏是否给定义了  这里就定义了一个SystemConfig.h 专门做这个事情  当然是需要make ...

  6. C# button 去边框

    Button属性里找到FlatStyle属性:Flat FlatAppearance BorderSize:0;

  7. ThinkPHP整合微信支付之发裂变红包

    1.去商户平台里,给你的商户充钱,没钱是发不了红包哒! 2.微信红包需要证书支持,所以请大家到商户平台下去下载好证书后放到安全文件夹下,并且需要在配置文件中指定好证书路径! 好,接下来带来裂变红包具体 ...

  8. cocos2d 保存最近登陆多个账号最多一个月

    用的是一个单例来管理 ,数据是存在本地的xml文件里的格式如下 <?xml version="1.0" encoding = "utf-8" ?> ...

  9. redis windows

    下载 redis windows版本 redis-server  redis.windows.conf  //cmd 命令 启动成功 E:\redis\Redis-x64-3.0.500>red ...

  10. 【转】AngularJS 取消对 HTML 片段的转义

    今天尝试用 Rails 做后端提供 JSON 格式的数据, AngularJS 做前端处理 JSON 数据,其中碰到 AngularJS 获取的是一段 HTML 文本,如果直接使用 data-ng-b ...