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. Java学习04 (第一遍)

    封装.抽象.继承和多态.封装:在面向对象语言中,封装特性是由类来体现的,我们将现实生活中的一类实体定义成类,其中包括属性和行为(在Java中就是方法),就好像人类,可以具有name,sex,age等属 ...

  2. Beanutils.copyProperties( )的使用与优化

    1.使用原因 因为现在都是前后端分离所以我们在响应APP端或者前端的时候会维护一套VO,那么DTO到VO的转换便是一堆get... set...这样的代码,比如好几个地方用到的话还要去复制粘贴来转换. ...

  3. linux 系统 网卡 ethX没有显示IP的处理方式

    1 临时方式 ifconfig  设备名 IP 地址 (ifconfig eth0  192.168.1.117) 设置好之后马上生效,不需要重启网卡服务(千万别重启网卡服务,不然刚刚设置的又没有了) ...

  4. Shiro在Spring session管理

    会话管理 在shiro里面可以发现所有的用户的会话信息都会由Shiro来进行控制,那么也就是说只要是与用户有关的一切的处理信息操作都可以通过Shiro取得,实际上可以取得的信息可以有用户名.主机名称等 ...

  5. pta l2-1紧急救援(Dijkstra)

    题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805073643683840 题意:给n个城市,m条边,每个城市 ...

  6. 数据存储 共享参数 SharedPreferences

    先要声明文件名和操作方式,第一个参数:文件名为"share.xml",第二个参数:私有模式SharedPreferences shared = getSharedPreferenc ...

  7. nth-child & nth-of-type区别

    Do l have to 非做不可吗? He is my age. 他和我同岁. Here you are. 给你. No one knows . 没有人知道. 关于nth-child &&a ...

  8. POJ 1177 Picture(线段树周长并)

      描述 A number of rectangular posters, photographs and other pictures of the same shape are pasted on ...

  9. Python中操作SQLAlchemy

    一.ORM 框架简介 对象-关系映射(Object/Relation Mapping,简称ORM),是随着面向对象的软件开发方法发展而产生的.面向对象的开发方法是当今企业级应用开发环境中的主流开发方法 ...

  10. LAB3 整数相加

    //yuec2 Yue Cheng package lab3; public class Fraction { int numerator; int denominator; //obeject wi ...