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 nwhere 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
代码:
import java.math.BigDecimal;
import java.util.Scanner; public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while(s.hasNext()){
BigDecimal b = s.nextBigDecimal();
BigDecimal ans = BigDecimal.valueOf(1);
int n = s.nextInt();
while(n-- > 0)
ans = ans.multiply(b);
String string = ans.stripTrailingZeros().toPlainString().toString();
if(string.startsWith("0."))
string = string.substring(1);
System.out.println(string);
}
s.close();
}
}
知识点总结
1、stripTrailingZeros() ,返回类型为BigDecimal的小于此数的但除去尾部的0的数值。
2、toPlainString(),返回BigDecimal类型的String类型字符串。
3、startsWith(),确定此实例的开头是否与指定的字符串匹配。
4、substring(),返回一个新的字符串,它是此字符串的一个子字符串。该子字符串始于指定索引处的字符,一直到此字符串末尾。

POJ-1001-Exponentiation(高精度大数)的更多相关文章

  1. POJ 1001 Exponentiation 无限大数的指数乘法 题解

    POJ做的非常好,本题就是要求一个无限位大的指数乘法结果. 要求基础:无限大数位相乘 额外要求:处理特殊情况的能力 -- 关键是考这个能力了. 所以本题的用例特别重要,再聪明的人也会疏忽某些用例的. ...

  2. POJ 1001 Exponentiation(大数运算)

    POJ 1001 Exponentiation 时限:500 ms   内存限制:10000 K 提交材料共计: 179923   接受: 43369 描述:求得数R( 0.0 < R < ...

  3. [POJ 1001] Exponentiation C++解题报告 JAVA解题报告

        Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 126980   Accepted: 30 ...

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

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

  5. poj 1001 Exponentiation 第一题 高精度 乘方 难度:1(非java)

    Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 138526   Accepted: 33859 ...

  6. Exponentiation(高精度大数)

    Exponentiation Description Problems involving the computation of exact values of very large magnitud ...

  7. POJ 1001 Exponentiation(JAVA,BigDecimal->String)

    题目 计算实数a的n次方,具体输出格式看案例 import java.util.*; import java.math.*; public class Main { public static voi ...

  8. POJ 1001 Exponentiation

    题意:求c的n次幂……要求保留所有小数…… 解法:一开始只知道有BigInteger……java大数+模拟.第一次写java大数……各种报错各种exception……ORZ 没有前导0和小数后面的补位 ...

  9. 1001. Exponentiation高精度运算总结

    解题思路 这道题属于高精度乘法运算,要求输入一个实数R一个指数N,求实数R的N次方,由于R有5个数位,而N又特别大,因此用C++自带的数据类型放不下. 解题思路是通过数组储存每次乘积结果和底数的每一位 ...

  10. poj 1001 求高精度幂(Java, BigDecimal, pow, hasNext, stripTrailingZeros, toPlainString)

    求高精度幂 Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 180325   Accepted: 43460 Descripti ...

随机推荐

  1. 【学习笔记】ThreadLocal与引用类型相关知识点

    0 写在前边 今天以 "TheadLocal 为什么会导致内存泄漏" 为题与朋友们讨论了一波,引出了一些原理性的内容,本文就这个问题作答,并扩展相关的知识点 1 ThreadLoc ...

  2. BN系列-未完待续

    BN.LN.IN.GN Cross-Iteration Batch Normalization 因为有时候我们的计算能力有限,所以BN设置的比较小,这样BN效果就比较差. 因此我们将最近几次的batc ...

  3. java List接口二

    一 ArrayList集合 ArrayList集合数据存储的结构是数组结构.元素增删慢,查找快,由于日常开发中使用最多的 功能为查询数据.遍历数据,所以ArrayList是最常用的集合. 许多程序员开 ...

  4. asp.netcore 3.1 program、Startup 类详解

    Program类 public class Program { /// <summary> /// 应用程序入口 /// 1.asp.netcore 本质上是控制台程序 /// </ ...

  5. day3 基本语句

         代码缩进为一个tab键  就是四个空格           断点   在代码首行前空白处,双击  然后点右上角臭虫  然后点下面箭头朝下的 1.if 语句  if 判断条件:         ...

  6. 《MySQL必知必会》检索数据,排序检索数据(select ,* ,distinct ,limit , . , order by ,desc)

    <MySQL必知必会>检索数据,排序检索数据 1.检索数据 1.1 select 语句 为了使用SELECT检索表数据,必须至少给出两条信息一想选择什 么,以及从什么地方选择. 1.2 检 ...

  7. html表格、表单

    知识点一:表格 1.表格标签  table 2.表格的组成  行 tr  单元格  td 3.建立表格步骤 1.建立表格, 2.判断行数和列数 3.用行去包含单元格 4.在每个单元格中去添加内容 4. ...

  8. sql server 查询表字段的说明备注信息

    SELECT 表名 = case when a.colorder= then d.name else '' end, 表说明 = case when a.colorder= then isnull(f ...

  9. jqgrid 获取选中用户的数据插入

    因为查询出的表和被插入的表不是在同一个数据库,所以先从前台jqgrid表格中获取到数据后,再插入表中. 实现: 获取到jqgrid选中 的每行数据之后,发ajax请求把数据以json格式传入后台,后台 ...

  10. RPC 框架 Dubbo 从理解到使用(一)

    技术架构演变 单一应用架构 通俗地讲,"单体应用(monolith application)"就是将应用程序的所有功能都打包成一个独立的单元.当网站流量很小时,只需一个应用,将所有 ...