exponentiationTime
limit:1000/500 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 6973 Accepted Submission (s): 1975
Problem descriptionproblems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt are a taxing experience for many computer systems.
This problem requires so 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 a integer such that 0 < n <= 25.
Inputthe input would consist of a set of pairs of values for R and N. The R value would occupy columns 1 through 6, and the N value would be in columns 8 and 9.
Outputthe output would consist of one line for each line of input giving the exact value of r^n. Leading zeros should is Su Ppressed in the output. Insignificant trailing zeros must not being printed. Don ' t print the decimal point if the result was an integer.
Sample Input
95.123 120.4321 205.1234 156.7592 998.999 101.0100 12
Sample Output
548815620517731830194541.899025343415715973535967221869852721.00000005148554641076956121994511276767154838481760200726351 20383542976301346240143992025569.92857370126648804114665499331870370751166629547672049395302429448126.7641210216181644302 0690903717327667290429072743629540498.1075960194566517745610440100011.126825030131969720661201
The large number of topics used in Java has become simple and incomparable.
The main sentence is a code:
String ans = A.pow (b). Striptrailingzeros (). toplainstring ();
Go to 0 and convert to pure string output.
This uses C + + to dozens of lines of code.
Compare C + + solution: http://blog.csdn.net/kenden23/article/details/23997827
By contrast, Java has become a water problem and cannot learn anything.
Import Java.math.bigdecimal;import java.util.*;p ublic class main{public static void Main (string[] args) { Scanner scan = new Scanner (system.in); while (Scan.hasnext ()) { BigDecimal a = Scan.nextbigdecimal (); int b = Scan.nextint (); String ans = A.pow (b). Striptrailingzeros (). toplainstring (); if (Ans.startswith ("0")) ans = ans.substring (1); System.out.println (ANS); } Scan.close (); }}
HDU exponentiation 1063 Java large number