Miyu original, post Please note: Reprinted from __________ White House
Question address: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1063
Description:
Exponentiation
Time Limit: 1000/500 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 1696 accepted submission (s): 376
Problem descriptionproblems involving the computation of exact values of very large magnstrap and precision are common. For example, the computation of the national debt is a taxing experience for your 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.
Inputthe 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.
Outputthe output will consist of one line for each line of input giving the exact value of R ^ n. leading zeros shocould 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
These two days I suddenly want to learn about the big numbers of Java. This problem is lost in PKU A, but it has never been passed in HDU, I don't know how disgusting the data is. It's depressing.
But I used Java to directly 1...
CodeAs follows:
/*
* To change this template, choose tools | templates
* And open the template in the editor.
*/
Import java. util. collections;
Import java. Math .*;
/**
*
* @ Author policyun
*/
Public class main {
/**
* @ Param ARGs the command line arguments
*/
Public static void main (string [] ARGs ){
Running in = New Processing (system. In );
Bigdecimal num;
Int exp;
While (in. hasnext ()){
Num = in. nextbigdecimal ();
Exp = in. nextint ();
Num = num. Pow (exp );
Num = num. striptrailingzeros ();
String out = num. toplainstring ();
If (Out. charat (0) = '0 ')
Out = out. substring (1 );
System. Out. println (out );
}
}
}