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 R n where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.
InputThe 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.
OutputThe 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
 import java.util.*;
import java.io.*;
import java.math.*;
import java.text.*; public class Main{
public static void main(String[] args){
BigDecimal x;
String ans;
int n;
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
x = cin.nextBigDecimal();
n = cin.nextInt();
ans = x.pow(n).stripTrailingZeros().toPlainString();//
if(ans.charAt()=='')
ans = ans.substring();
System.out.println(ans);
}
}
} // BigDecimal是处理高精度的浮点数运算的常用的一个类
// 当需要将BigDecimal中保存的浮点数值打印出来,特别是在页面上显示的时候,就有可能遇到预想之外的科学技术法表示的问题。
// 一般直接使用 BigDecimal.toString()方法即可以完成浮点数的打印。
// 如:
// System.out.println( new BigDecimal("10000000000").toString());
// 但是,toString()方法输出的字符串并不能保证不是科学计数法。
// 不过在日常的使用中,用toString()方法输出的就是普通的数字字符串而非科学计数法。
// 直接这么写:
// System.out.println( new BigDecimal("100.000").toString());
// 程序的输出即为: 100.000
// 如果我们希望去除末尾多余的0,那么我们应该这么写:
// System.out.println( new BigDecimal("100.000").stripTrailingZeros().toString());
// 其中,stripTrailingZeros()函数就是用于去除末尾多余的0的,但是此时程序的输出为: 1E+2
// 是科学计数法,可能并不是我们想要的。
// 解决的方法很简单,如果想要避免输出科学计数法的字符串,我们要用toPlainString()函数代替toString()。如:
// System.out.println( new BigDecimal("100.000").stripTrailingZeros().toPlainString());
// 此时程序的输出就为 100

大数java(pow)的更多相关文章

  1. HDU 1715 大数java

    大菲波数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  2. HDU1063 大数 java

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

  3. HDU1134/HDU1133 递推 大数 java

    Game of Connections Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  4. How Many Fibs_hdu_1316(大数).java

    How Many Fibs? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T ...

  5. Integer Inquiry_hdu_1047(大数).java

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  6. java求两个数中的大数

    java求两个数中的大数 java中的max函数在Math中 应用如下: int a=34: int b=45: int ans=Math.max(34,45); 那么ans的值就是45.

  7. (大数)Computer Transformation hdu1041

    Computer Transformation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/ ...

  8. CF1245 A. Good ol' Numbers Coloring(java与gcd)

    题意:给定数字A和数字B,问是否满足gcd(A,B)==1. 思路:可以直接写函数gcd.也可以用大数自带的gcd功能. 代码1: /* @author nimphy @create 2019-11- ...

  9. Java 求解自幂数(水仙花数)

    什么是自幂数 如果在一个固定的进制中,一个 n 位自然数等于自身各个数位上数字的 n 次幂之和,则称此数为自幂数. 例如:在十进制中,153 是一个三位数,各个数位的3次幂之和为 1^3+5^3+3^ ...

随机推荐

  1. CDH6离线安装

    CentOS7下完全离线安装CDH6集群   CDH Linux 大数据 shareSHARE   245 浏览量 分享到微博 分享到 Twitter 分享到 QQ 本文是在CentOS7.5下进行C ...

  2. webuploader.js

    PHP  多图上传,图片批量上传插件,webuploader.js,百度文件上传插件(案例教程) WebUploader作用: 使用WebUploader还可以批量上传文件.支持缩略图等等众多参数选项 ...

  3. centos7升级内核

    载入elrepo源,搜索内核更新资源,并进行更新操作. 具体实验步骤: # 载入公钥rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org ...

  4. Ubuntu系统下手动释放内存

    有时候,像mongo这种,对内存只吃不吐的,我们要手动释放一下. drop_caches的详细文档如下:Writing to this will cause the kernel to drop cl ...

  5. Linux命令_2

    P42 远程管理 命令 目标 关机/重启 shutdown 查看或配置网卡信息 ifconfig ping 远程登录和复制文件 ssh scp 01.关机/重启 命令: shutdown  选项  时 ...

  6. Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag.

    https://blog.csdn.net/watermusicyes/article/details/44963773 Context中有一个startActivity方法,Activity继承自C ...

  7. 基于oslo_messaging的RPC通信

    oslo_messaging源于Openstack的一个经典的模块,用以实现服务间的RPC通信.Client端将数据放入rabbitmq中,server端从消息队列中获取传送数据. oslo.mess ...

  8. 四、Factory Method 工厂方法模式

    需求:对象的创建由工厂统一创建,会使用到模板模式 代码清单: 工厂: public abstract class Factory { public abstract Product createPro ...

  9. 三、Template 模板模式

    需求:有规格的尺子,不管何种笔写,写出的字大小.形状都是一样的?抽象为处理流程一致,仅仅是不同的实现 代码清单: 抽象类: public abstract class AbstractDisplay{ ...

  10. oracle 存储过程模板

    CREATE OR REPLACEPROCEDURE PROCE_NAME(V_IN varchar2, V_OUT out varchar2) ASBEGIN --...  commit;  V_O ...