Problem Description
Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems.




This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.

 
Input
The input will consist of a set of pairs of values for R and n. The R value will occupy columns 1 through 6, and the n value will be in columns 8 and 9.
 
Output
The output will consist of one line for each line of input giving the exact value of R^n. Leading zeros should be suppressed in the output. Insignificant trailing zeros must not be printed. Don't print the decimal point if the result
is an integer.
 
Sample Input
95.123 12
0.4321 20
5.1234 15
6.7592 9
98.999 10
1.0100 12
 
Sample Output
548815620517731830194541.899025343415715973535967221869852721
.00000005148554641076956121994511276767154838481760200726351203835429763013462401
43992025569.928573701266488041146654993318703707511666295476720493953024
29448126.764121021618164430206909037173276672
90429072743629540498.107596019456651774561044010001
1.126825030131969720661201 要求的是一个大数a的n次方 只是还有几个条件。比方例二。小数点前为0要删除。
代码:
import java.math.BigDecimal;
import java.util.Scanner;
public class Main{
public static void main(String[] srgs)
{
Scanner cin =new Scanner(System.in);
BigDecimal a,s;
int i,n;
while(cin.hasNext())
{
a=cin.nextBigDecimal();
n=cin.nextInt();
s=a;
for(i=1;i<n;i++)
s=s.multiply(a);
s=s.stripTrailingZeros(); //去掉末尾所以的0
String ss=s.toPlainString(); //不准用科学计数的形式输出(e)。
if(ss.charAt(0)=='0') //推断ss第0位是否为0
{
ss=ss.substring(1); //从第一位截取
}
System.out.println(ss);
}
}
}

hdu 1063 Exponentiation 大数的更多相关文章

  1. hdu 1063 Exponentiation (高精度小数乘法)

    //大数继续,额,要吐了. Problem Description Problems involving the computation of exact values of very large m ...

  2. hdu 1063 Exponentiation

    求实数的幂,这个用C++写的话有点长,但是用Java写就非常方便了…… );            System.out.println(an);        }    }}

  3. HDU Exponentiation 1063 Java大数题解

    Exponentiation Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  4. HDU ACM 1063 Exponentiation 大实数乘方

    分析:大实数乘方计算. #include<iostream> #include<string> using namespace std; struct BigReal //高精 ...

  5. hdu 1063(java写高精度)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1063 思路:最近刚学了java,然后就迫不及待想试试java写大数的好处了,呵呵,果然是很方便啊! i ...

  6. HDU 5047 Sawtooth(大数模拟)上海赛区网赛1006

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5047 解题报告:问一个“M”型可以把一个矩形的平面最多分割成多少块. 输入是有n个“M",现 ...

  7. [POJ] #1001# Exponentiation : 大数乘法

    一. 题目 Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 156373   Accepted: ...

  8. HDU 1715 (大数相加,斐波拉契数列)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1715 大菲波数 Time Limit: 1000/1000 MS (Java/Others)     ...

  9. hdu 5718(Oracle)大数加法

    曾经有一位国王,统治着一片未名之地.他膝下有三个女儿. 三个女儿中最年轻漂亮的当属Psyche.她的父亲不确定她未来的命运,于是他来到Delphi神庙求神谕. 神谕可以看作一个不含前导零的正整数n n ...

随机推荐

  1. HTML常用标签属性图

  2. HTML+CSS - 搜索 And 高级搜索

  3. Codility上的问题 (17) PI 2012

    这个题比较简单,给定一个整数数组,对每个元素,求出和它最近比它大的数的距离(下标绝对值),如果没有比它大的数,认为距离是0. 数组元素个数 N [0..50000],数组元素范围[-10^9, +10 ...

  4. Swift - 程序进入后台,以及应用终止时调用的方法

    在AppDelegate中有如下两个方法要注意: applicationDidEnterBackground()  当应用进入后台时起作用 applicationWillTerminate()  当应 ...

  5. 编译android-4.3.1_r源代码并刷到自己的Galaxy Nexus I9250真机上

    编译android-4.3.1_r源代码并刷到自己的Galaxy Nexus I9250真机上 作者:雨水  日期:2014-04-30 编译源码的目的还是为了自己改动源码,然后还可以执行在相应的手机 ...

  6. 【翻译】十大要避免的Ext JS开发方法

    原文地址:http://www.sencha.com/blog/top-10-ext-js-development-practices-to-avoid/ 作者:Sean Lanktree Sean ...

  7. DELPHI SOKET 编程(使用TServerSocket和TClientSocket)

    本文采用delphi7+TServerSocket+TClientSocket; 笔者在工作中遇到对局域网中各工作站与服务器之间进行Socket通信的问题.现在将本人总结出来的TServerSocke ...

  8. 百度地图new BMap.LocalCity() 问题

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  9. Android菜鸟的成长笔记(10)——使用Bundle在Activity之间传值

    原文:[置顶] Android菜鸟的成长笔记(10)——使用Bundle在Activity之间传值 前面我们了解了如何启动一个Activity,一个Activity在启动另外一个Activity的时候 ...

  10. 安装logstash,elasticsearch,kibana三件套(转)

    logstash,elasticsearch,kibana三件套 elk是指logstash,elasticsearch,kibana三件套,这三件套可以组成日志分析和监控工具 注意: 关于安装文档, ...