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. Unity3D使用TCP/IP协议,传递protocol buffer消息protobuf-net

    原文:http://my.oschina.net/faint/blog/296785 第一部分 dll 1 下面大多数内容,都是使用c#编译的dll来实现的. 2 编译为dll后,要拖放到unity3 ...

  2. J2SE语言--百度百科

    Java2平台包括:标准版(J2SE).企业版(J2EE)和微缩版 (J2ME)三个版本.J2SE,J2ME和J2EE,这也就是SunONE(Open NetEnvironment)体系.J2SE就是 ...

  3. grid 布局一 固定宽度+自适应宽度

    <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...

  4. HTML 5 中WebStorage实现数据本地存储

    webstorage 分sessionStorage和localstorage,sessionStorage是暂时保存,localStorage是永久保存. sessionStorage假设浏览器关闭 ...

  5. 【Python3 爬虫】10_Beautiful Soup库的使用

    之前学习了正则表达式,但是发现如果用正则表达式写网络爬虫,那是相当的复杂啊!于是就有了Beautiful Soup 简单来说,Beautiful Soup是python的一个库,最主要的功能是从网页抓 ...

  6. 【Java】Java_10 常量与变量

    1.变量(variable) 1.1 我们通过变量来操纵存储空间中的数据,变量就是指代这个存储空间!空间位置是确定的,但是里面放置什么值不确定! 1.2 Java是一种强类型语言,每个变量都必须声明其 ...

  7. 《Mining the Web:Transforming Customer Data into Customer Value》读后札记

    <Mining the Web:Transforming Customer Data into Customer Value> <Web数据挖掘:将客户数据转化为客户价值> — ...

  8. Cocos2dx报OpenGL error 0x0506错误

    近期做第三方sdk接入时,发现iOS8系统下,进行银联充值后,返回游戏有很大几率会报 OpenGL error 0x0506............ 之类的绘制问题,游戏卡死,花了很长时间,一直没有头 ...

  9. 嵌入式实时操作系统Nucleus PLUS综述

    近些年来,随着嵌入式系统飞速的发展.嵌入式实时操作系统广泛地应用在制造工业.过程控制.通讯.仪器仪表.汽车.船舶.航空航天.军事.装备.消费类产 品等方面. Nucleus PLUS 是为实时嵌入式应 ...

  10. C++ Primer Plus的若干收获--(二)

    哎,真是不想吐槽考驾照的艰辛历程了.跑到大西郊,顶着大太阳,一天就能摸上个十几分钟二十分钟的车,简直不要太坑爹,这两天真是做的我屁股疼的不行. .. 今天果断不去了.仅仅可惜我的大阿根廷啊,坚持到最后 ...