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. 吴裕雄 python 爬虫(4)

    import requests user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, li ...

  2. zabbix 分布式zabbix_proxy

    Zabbix是一个分布式监控系统,它可以以一个中心点.多个分节点的模式运行,使用Proxy能大大的降低Zabbix Server的压力,Zabbix Proxy可以运行在独立的服务器上 1)下载zab ...

  3. webpack 中使用 vue-router 注意

    //render 会把el指定的容器中所有的内容都清空把#app也会去掉 都在c(app)其中的app组件中展示 所有router-link router-view要写在app这个组件里面   //A ...

  4. yii gii配置ip限制使用gii

    <?php $config = [ 'components' => [ 'request' => [ // !!! insert a secret key in the follow ...

  5. lcd 显示屏

    1.lcd 接口信号: VSYNC : 一帧新数据的开始信号 HSYNC :一行新数据的开始信号 VCLK   :像素的同步信号 VD[0:23]  :传递数据的信号线 2. LCD  的显示原理 ( ...

  6. veil-evasion免杀处理

    veil-evasion 开启 y 配置安装 安装好之后,再次运行veil-evasion 有50个payload模块 update 升级 list 查看有哪些payload 选一个payload 它 ...

  7. SoundChannel和soundTransform的关系

    SoundChannel 音乐的  播放  暂停  当前获取当前位置  长度 leftPeak : Number[只读] 左声道的当前幅度(音量),范围从 0(静音)至 1(最大幅度) rightPe ...

  8. 求组合数的O(n^2)和O(n)解法及模板

    概率论中的组合数应该比较熟悉吧,在数论中组合数也具有重大意义,下面介绍组合数的解法: 方法一O(n^2): 利用公式(n,m)=(n-1,m-1)+(n-1,m): 模板: #include<c ...

  9. CentOS 下搭建SVN

    CentOS 7下搭建配置SVN服务器 1. 安装 CentOS通过yum安装subversion. $ sudo yum install subversion subversion安装在/bin目录 ...

  10. 转化为分组背包 zoj 3769

    题目链接:https://vjudge.net/problem/ZOJ-3769 题意:现在你要去打怪,你有13种装备,每件装备会有伤害和防御两种属性,一般来说,每种装备只可以装备一件,但是特别的,戒 ...