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
  1. 1427 0
  2.  
  3. 876652098643267843
  4. 5276538
  1. 2297.0716
  2. 936297014.1164
  3. 0.0000
  4. 37.7757

译文:

输入:

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

输出:

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

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

第一次code:

  1. import java.math.BigDecimal;
  2. import java.math.RoundingMode;
  3. import java.util.Scanner;
  4.  
  5. public class Main
  6. {
  7. public static void main(String[] args)
  8. {
  9. Scanner input = new Scanner(System.in);
  10. long[]a = new long[1000000000];
  11. int i;
  12. for (i=0; input.hasNext(); i++)
  13. {
  14. a[i] = input.nextLong();
  15. }
  16. for(i--;i>-1;i--)
  17. {
  18. /**
  19. * Math.sqrt() : 对数据求平方
  20. * BigDecimal适用于大型数据计算,精确度高
  21. */
  22. BigDecimal b = new BigDecimal(Math.sqrt(a[i]));
  23. System.out.println(b.setScale(4,RoundingMode.HALF_UP).toString());
  24. }
  25. }
  26. }

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

/*

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

*/

  1. import java.math.BigDecimal;
  2. import java.math.RoundingMode;
  3. import java.util.Scanner;
  4.  
  5. public class Main
  6. {
  7. public static void main(String[] args)
  8. {
  9. Scanner input = new Scanner(System.in);
  10. int n =input.nextInt();
  11. run();
  12. }
  13. public static void run()
  14. {
  15. Scanner input = new Scanner(System.in);
  16. long[]a = new long[n];
  17. int i;
  18. for (i=0; i<n; i++)
  19. {
  20. a[i] = input.nextLong();
  21. }
  22. for(i--;i>-1;i--)
  23. {
  24. BigDecimal b = new BigDecimal(Math.sqrt(a[i]));
  25. System.out.println(b.setScale(4,RoundingMode.HALF_UP).toString());
  26. }
  27. }
  28. }

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. linux信号处理时机

    信号号称所谓软中断,事实上,还是没有真正的硬件中断那样能随时改变cpu的执行流 硬件中断之所以能一发生就得到处理是因为处理器在每个指令周期的结尾都会去检查中断,这种粒度是很细的 但是信号的实现只是在进 ...

  2. C#中this在扩展方法的应用

    给类添加扩展方法 1.定义一个类Service public class Service { private string _name; public string Name { get { retu ...

  3. 转 纯CSS设置Checkbox复选框控件的样式

    Checkbox复选框是一个可能每一个网站都在使用的HTML元素,但大多数人并不给它们设置样式,所以在绝大多数网站它们看起来是一样的.为什么不把你的网站中的Checkbox设置一个与众不同的样式,甚至 ...

  4. 网页闯关游戏(riddle webgame)--仿微信聊天的前端页面设计和难点

    前言: 之前编写了一个网页闯关游戏(类似Riddle Game), 除了希望大家能够体验一下我的游戏外. 也愿意分享编写这个网页游戏过程中, 学到的一些知识. 本文讲描述, 如何在网页端实现一个仿微信 ...

  5. LintCode First Bad Version

    找出第一个出问题的version. /** * public class SVNRepo { * public static boolean isBadVersion(int k); * } * yo ...

  6. Chrome渲染Transition时页面闪动Bug

    前段时间,有同事和会员反馈使用Chrome访问淘宝首页会出现画面闪动的现象,但是我在Mac和Win下面的Chrome都无法重现这个问题,后来重装了一遍Win7下的Chrome Beta版本,终于重现了 ...

  7. Python中optionParser模块的使用方法[转]

    本文以实例形式较为详尽的讲述了Python中optionParser模块的使用方法,对于深入学习Python有很好的借鉴价值.分享给大家供大家参考之用.具体分析如下: 一般来说,Python中有两个内 ...

  8. 有关使用seajs和template模板的总结

    方法一:使用<script type="text/javascript" src="../js/lib/template.js"></scri ...

  9. ASP.NET获取IP的6种方法 ( 转)

    原文转自:http://www.cnblogs.com/blodfox777/archive/2008/07/21/1247447.html 服务端: //方法一 HttpContext.Curren ...

  10. php发送post包

    class Request{ public static function post($url, $post_data = '', $timeout = 5){//curl $ch = curl_in ...