Exponentiation

Description

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 Rn where 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

Hint

If you don't know how to determine wheather encounted the end of input: 
s is a string and n is an integer

//计算 n 的 x 次方

//显然,是个大数题,正好来练练java,格式要控制好。

 import java.math.BigDecimal;
import java.util.Scanner;
import java.lang.String; /**
* Created by happy_code on 2017/6/6.
*/
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s;
int n;
while (sc.hasNext())
{
s=sc.next();
n=sc.nextInt();
BigDecimal base = new BigDecimal(s);
BigDecimal res = new BigDecimal("");
for (int i=;i<n;i++){
res = res.multiply(base);
}
String ans = res.toPlainString(); boolean ok = false;
int k;
for (k =;k<ans.length();k++){
if (ans.charAt(k)=='.'){
ok = true;
break;
}
}
int e=ans.length()-;
if (ok){
while(ans.charAt(e)=='') e--;
if (ans.charAt(e)=='.') e--;
}
int i = ;
while(ans.charAt(i)=='') i++;
for (;i<=e;i++){
if (i==&&ans.charAt(i)==''){
continue;
}
System.out.print(ans.charAt(i));
}
System.out.println();
}
}
}

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

  1. uva748 - Exponentiation 高精度小数的幂运算

    uva748 - Exponentiation   Exponentiation  Problems involving the computation of exact values of very ...

  2. Exponentiation java大数

    Exponentiation 大数a的n次幂,直到读到EOF(文件结尾)为止,其中忽略小数后面的0 1 import java.util.*; 2 import java.math.*; 3 impo ...

  3. hdu 1063 Exponentiation (高精度小数乘法)

    //大数继续,额,要吐了. Problem Description Problems involving the computation of exact values of very large m ...

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

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

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

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

  6. 【POJ 1001】Exponentiation (高精度乘法+快速幂)

    BUPT2017 wintertraining(15) #6A 题意 求\(R^n\) ( 0.0 < R < 99.999 )(0 < n <= 25) 题解 将R用字符串读 ...

  7. Hdu 4762 网络赛 高精度大数模板+概率

    注意题目中的这句话he put the strawberries on the cake randomly one by one,第一次选择草莓其实有N个可能,以某一个草莓为开头,然后顺序的随机摆放, ...

  8. POJ-1001 Exponentiation 高精度算法

    题目链接:https://cn.vjudge.net/problem/POJ-1001 以前写过一个高精度乘法,但是没有小数点,实现起来也没什么难得, 现在把代码都般过来,等会把旧电脑弄一弄,暂时就不 ...

  9. PAT A1024题解——高精度大数相加模板

    PAT:A1024 Palindromic Number A number that will be the same when it is written forwards or backwards ...

随机推荐

  1. Java8 对多个异步任务进行流水线操作(笔记)

    现在我们要对商店商品进行折扣服务.每个折扣代码对应不同的折扣率,使用一个枚举变量Discount.Code来实现这一想法,具体代码如下所示. 以枚举类型定义的折扣代码 /** * 折扣服务api * ...

  2. [转]2年SQL Server DBA调优方面总结

      2年SQL Server DBA调优方面总结 当2年dba 我觉得,有些东西需要和大家分享探讨,先书单. 书单 1.<深入解析SQL Server 2008 系列> 这个就是mssql ...

  3. python 对比学习

    python和java面向对象的不同 1.属性和方法 java中类的属性(static)除外,对象全部独立拥有: 而python中类的属性,其实例对象一个字段都没有.底层是这么搞的: 对象object ...

  4. linux小技巧(1)

    1.避免文件夹拼写错误 shopt命令: 演示一下: 我想进入/home文件夹可是不小心拼写错了: [fulinux@ubuntu ~]$ cd /hoem-bash: cd: /hoem: No s ...

  5. Android Framework 分析---2消息机制Native层

    在Android的消息机制中.不仅提供了供Application 开发使用的java的消息循环.事实上java的机制终于还是靠native来实现的.在native不仅提供一套消息传递和处理的机制,还提 ...

  6. STM32 通用T2、T3、T4、T5定时器详解

    定时器初始化配置 void TIM3_Configuration(void)//1MS { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_DeI ...

  7. ELF解析(part one)

    the contents class elf { //date structure Elf32_Ehdr ehdr; Elf32_Shdr shdr; Elf32_Phdr phdr; // void ...

  8. 串行 RapidIO

    https://wenku.baidu.com/view/78666616cf84b9d528ea7ad9.html

  9. ubuntu 新建一个root用户

    1. 新建一个终端(Applications menu -> Accessories -> Terminal), 输入: sudo –s sudo passwd 输入要设置的密码,这样以后 ...

  10. 在Linux命令行下发送html格式的邮件

    在Linux利用formail+sendmail来发送带图片的邮件 formail接收html格式的文件作为邮件的内容,这样就可以解决发送带图片邮件的问题了,因为html中可以插入图片,只要给出的im ...