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. 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-可以用软件自带NC工具驱动但是程序无法让电机转动怎么办

    新建一个项目,当扫描的时候务必勾选YES,使用网上最新的XML文件   如果不使用,则有些设备可能被扫描出来是无效的(图标不正常)   如果完全删除XML描述文件,可能也能扫描出来,而且可以用Twin ...

  2. &lt;十&gt;读&lt;&lt;大话设计模式&gt;&gt;之观察者模式

    观察者模式也是比較简单的一种模式,可能从名字上理解无法明确,但真正理解其含义之后就非常easy了,说实话在自己来发的项目中自己也用到过.仅仅只是不知道它叫观察者罢了,仅仅要懂面向对象的对继承多态理解非 ...

  3. Openerp图片路径处理

    Openerp目前存储图片如人力资源头像图片等都是以二进制的方式存储在数据库中,若要修改数据库里只存储路径可以用这种方法 Image 装饰器: Image装饰器包含3中图片显示 Image 大图片 i ...

  4. 访问vector元素方法的效率比较(转)

    LInux下: gcc 4.47,red hat6 #include<iostream> #include<vector> #include<time.h> usi ...

  5. Linux下中断程序导致写文件失败的分析

    案例: 一个普通linux C程序,执行期间会进行多次printf操作,利用bash脚本重定向功能,将stdout重定向到一个另一个文件中去.在运行途中用ctrl+C终止程序,发现定向文件始终为空,即 ...

  6. WireShake的使用

    转自点击打开链接 之前写过一篇博客:用 Fiddler 来调试HTTP,HTTPS. 这篇文章介绍另一个好用的抓包工具wireshark, 用来获取网络数据封包,包括http,TCP,UDP,等网络协 ...

  7. ios 调试过程捕获异常Stack 信息

    在AppDelegate,定义方法 void catchExceptionHandler(NSException *exception) { NSLog(@"CRASH: %@", ...

  8. 8.1.2 绑定Activity和Service

    8.1.2 绑定Activity和Service 2010-06-21 16:57 李宁 中国水利水电出版社 字号:T | T <Android/OPhone开发完全讲义>第8章Andro ...

  9. ssl中间证书

    中间证书,其实也叫中间CA(中间证书颁发机构,Intermediate certificate authority, Intermedia CA),对应的是根证书颁发机构(Root certifica ...

  10. GuozhongCrawler系列教程 (2) CrawTaskBuilder具体解释

    GuozhongCrawler是分层架构.要高速学习CrawlTask独立的配置多少要了解框架的源码.所以CrawTaskBuilder提供要更加扁平且易于理解的的方式创建CrawTask 方法具体资 ...