Exponentiation

Time Limit: 500MS Memory Limit: 10000K

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

import java.math.BigDecimal;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
        BigDecimal R= sc.nextBigDecimal();
        int n=sc.nextInt();
         R=R.pow(n);
         String str=R.stripTrailingZeros().toPlainString();
          if(str.startsWith("0."))
              str=str.substring(1);
          System.out.println(str);
        }
        sc.close();
    }

}

-----------------------------------------

1、stripTrailingZeros() ,返回类型为BigDecimal的小于此数的但除去尾部的0的数值。

2、toPlainString(),返回BigDecimal类型的String类型字符串。

3、startsWith(),确定此实例的开头是否与指定的字符串匹配。

4、substring(),返回一个新的字符串,它是此字符串的一个子字符串。该子字符串始于指定索引处的字符,一直到此字符串末尾。

时间: 2024-08-02 06:55:39

Exponentiation的相关文章

poj1001 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

hdu 1063 Exponentiation

http://acm.hdu.edu.cn/showproblem.php?pid=1063 1 import java.math.BigDecimal; 2 import java.util.*; 3 public class Main { 4 public static void main(String []args) 5 { 6 Scanner cin=new Scanner(System.in); 7 BigDecimal r,mutil; 8 String ans; 9 int n;

POJ 1001 Exponentiation

Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 171995   Accepted: 41641 Description Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the n

HDU Exponentiation 1063 Java大数题解

Exponentiation Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6973    Accepted Submission(s): 1975 Problem Description Problems involving the computation of exact values of very large magnitude

POJ Exponentiation(大浮点数JAVA轻松解决)

题目链接:Clicke Here~ java解决大数就是爽阿!~ 以前大数模板敲啊敲的,敲了半天发现一交果断wrong.只从学会了java妈妈在不用担心我遇到大数了/ 这道题遇到的Java函数有: stripTrailingZeros()            去掉后缀0 toPlainString()               返回大数的非科学计数法 startsWith() startsWith()函数介绍及扩展: 描述 startsWith(),endsWith()的作用,用法,判断字符

Exponentiation UVA 748

//算法:获得无小数点的输入串,然后对该串进行普通的高精度乘法运算 //运算得到结果后,添加小数点,最后除去串头和串尾的0即可 #include <stdio.h> #define MAXN 200 char R[10]; char E[6];//寄存无小数点的输入串 char temp[MAXN]; char ans[MAXN];//寄存答案串 int n,left; void multip(); int main(){ int i,j,k; int cnt; // freopen(&quo

HDOJ 1063 Exponentiation

JAVA大数.... xx.stripTrailingZeros().toPlainString() 去末尾的0并不用科学计数法显示 Exponentiation Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6740    Accepted Submission(s): 1882 Problem Description Problem

[POJ] #1002# Exponentiation : 大数乘法

一. 题目 Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 156373   Accepted: 38086 Description Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of

Exponentiation(java 大实数)

http://acm.hdu.edu.cn/showproblem.php?pid=1063 Exponentiation Time Limit: 2000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8076    Accepted Submission(s): 2279 Problem Description Problems involving the compu

uva748 - Exponentiation

import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class Exponentiation { public static void main(String[] args){ Scanner sc = new Scanner(new BufferedInputStream(System.in)); BigDecimal bd1, ans; DecimalFormat df =