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. Applese涂颜色-欧拉降幂公式

    链接:https://ac.nowcoder.com/acm/contest/330/E来源:牛客网 题目描述 精通程序设计的 Applese 叕写了一个游戏. 在这个游戏中,有一个 n 行 m 列的 ...

  2. jQuery之dom操作(取赋值方法)

    取赋值相关方法:                   .html() .text() .size()                   .addClass() .removeClass() .has ...

  3. js基础-运算符

    100 * "20" 字符串转数字 5 * "ss"  NAN "ss" 转数字返回NAN 任何数字与NAN +-*/ 都返回NAN 5/N ...

  4. jquery 获取表单的用户输入值的方法

    以前的表单中的select input textarea的用户选择输入是通过jQuery的val()方法获取到的,在三一Java前端大拿教我了一个方法可以不用那么麻烦获取数据,只要在这些表单元素上加n ...

  5. 1.3、CDH 搭建Hadoop在安装之前(端口)

    端口 Cloudera Manager,CDH组件,托管服务和第三方组件使用下表中列出的端口.在部署Cloudera Manager,CDH和托管服务以及第三方组件之前,请确保在每个系统上打开这些端口 ...

  6. ORACLE 把不是SYS用户下的所有JOB删除掉

    BEGIN  FOR job_id in(select job,log_user,priv_user,schema_user from dba_jobs)   LOOP    IF(job_id.lo ...

  7. Oracle中dbms_random.string 的用法

    转载:https://blog.csdn.net/simonchi/article/details/8657787 DBMS_RANDOM.STRING(var1,var2) 这个函数有两个参数 va ...

  8. Android笔记:ContextMenu

    ContextMenu,称为上下文菜单,也就是长按界面不放,弹出的菜单.使用ContextMenu有三个步骤: (1)调用registerForContextMenu()方法,为视图注册上下文菜单: ...

  9. as3.0用了视频组件,导致视频打开后就全屏,加一下代码就行

    myFlv.fullScreenTakeOver = false; fullScreenTakeOver : Boolean 舞台进入全屏模式时,FLVPlayback 组件位于所有内容的顶部并占据整 ...

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

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