High precision Power time limit: Ms | Memory limit: 65535 KB Difficulty: 2
-
Describe
-
It is a very common problem to calculate high-precision numbers with large numbers and high precision. For example, the calculation of national debt is a question of this kind.
Now the problem you're solving is: for a real number R (0.0 < R < 99.999), the write program is required to accurately calculate the n-th (Rn) of R, where n is an integer and 0 < =n <= 25.
-
-
Input
-
-
input has more than one line, each line has two numbers r and N, separated by a space. The number of digits in R does not exceed 10 digits.
-
-
Output
-
-
for each set of inputs, an output line is required, which contains the exact n-th of R. The output needs to be removed from the leading 0 after 0. If the output is an integer, do not output a decimal point.
-
-
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
Focus: note suffix 0, leading 0;
Code:
Package essay; import Java.math.bigdecimal;import Java.util.Scanner; Public classHigh precision Power { Public Static voidMain (string[] argv) {Scanner cin=NewScanner (System.inch); while(Cin.hasnext ()) {BigDecimal R=Cin.nextbigdecimal (); intn =Cin.nextint (); String s=R.pow (n). Striptrailingzeros (). toplainstring (); while(S.startswith ("0")) S= S.substring (1); System. out. println (s); } }}
High precision Power (Java)