Timus Online Judge 1001. Reverse Root
Input
Output
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的更多相关文章
- Ural 1001 - Reverse Root
The problem is so easy, that the authors were lazy to write a statement for it! Input The input stre ...
- URAL 1001 Reverse Root(水题?)
The problem is so easy, that the authors were lazy to write a statement for it! Input The input stre ...
- Timus Online Judge:ural:1006. Square Frames
原题链接:http://acm.timus.ru/problem.aspx?space=1&num=1006 看到题第一反应:这玩意怎么读入…… 本地的话因为是全角字符,会占两个位置,所以需要 ...
- 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 ...
- 数论ex
数论ex 数学学得太差了补补知识点or复习 Miller-Rabin 和 Pollard Rho Miller-Rabin 前置知识: 费马小定理 \[ a^{p-1}\equiv 1\pmod p, ...
- Timus 1712. Cipher Grille 题解
版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/.未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...
- [轉]Reverse a singly linked list
Reverse a singly linked list http://angelonotes.blogspot.tw/2011/08/reverse-singly-linked-list.html ...
- 项目cobbler+lamp+vsftp+nfs+数据实时同步(inotify+rsync)
先配置好epel源 [root@node3 ~]#yum install epel-release -y 关闭防火墙和selinux [root@node3 ~]#iptables -F [root@ ...
- BZOJ1269——[AHOI2006]文本编辑器editor
1.题意:各种splay操作,一道好的模板题2333 2.分析:splay模板题,没啥解释QAQ #include <stack> #include <cstdio> #inc ...
随机推荐
- 关于重定向urlrewriter.urlmapping
大家都知道web.config 中的 urlMappings怎么用 <system.web> <urlMappings enabled="true"> &l ...
- LR接口测试手工脚本与验证脚本
Action(){ char URL[250]; char mars_cid[30]; memset(URL,0,sizeof(URL)); memset(mars_cid,0,sizeof(mars ...
- BLE Hacking:使用Ubertooth one扫描嗅探低功耗蓝牙
0×00 前言 低功耗蓝牙(Low Energy; LE),又视为Bluetooth Smart或蓝牙核心规格4.0版本.其特点具备节能.便于采用,是蓝牙技术专为物联网(Internet of Thi ...
- Android刷新Dialog
在编写数独游戏时遇到一个问题,当我一次游戏成功后会弹出一个dialog,告诉玩家当前的游戏难度,积分和所用时间,我在onCreateDialog中setMessage之后发现内容一直是不变的,后来找到 ...
- 集合运算(A-B)U(B-A)
实质是两个数组的合并(顺序表最好是有序的) #include<iostream> using namespace std; //创建顺序表 void create(int A[],int ...
- PHP性能分析 - ngnx日志分析
最终结果展示图: 图解:响应时间在40ms以内的请求数占请求总量的7%,40到80ms的的请求数占32.9%,依次类推... 性能问题有很多种可能,普通的情况通过xhprof可查得主要的性能损耗.但有 ...
- [GodLove]Wine93 Tarining Round #3
比赛链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=44857#overview 题目来源: ZOJ Monthly, July 2 ...
- 深入解析Javascript闭包
首先给个例子: function PfnOuter(){ var num=999; function PfnInner(){ alert(num); } return PfnInner; } var ...
- Java数据结构和算法之哈希表
五.哈希表 一般的线性表.树中,记录在结构中的相对位置是随机的即和记录的关键字之间不存在确定的关系,在结构中查找记录时需进行一系列和关键字的比较.这一类查找方法建立在“比较”的基础上,查找的效率与比较 ...
- 这些 Git 技能够你用一年了
这些 Git 技能够你用一年了 原文出处: Pyper 用git有一年了,下面是我这一年来的git使用总结,覆盖了日常使用中绝大多数的场景.嗯,至少是够用一年了,整理出来分享给大家,不明白的地方可以回 ...