1873 Math Base time limit for junior High: 1 seconds Space limit: 131072 KB Score: 10 Difficulty: 2-level algorithm topic collection attention
Noder now on the third day, is beginning to review the examination. He had to calculate the type every day as(AX ax ax ? X a )n A The formula. which 0.0<a<99.999,0<n< .
Although Noder will calculate, but is always wrong, now he wants you to write a program to output the correct results for him to check.
Input
A single set of test data. The first line has a real number A and an integer n, and the middle is separated by a space. 0.0 < A < 99.999,a always occupies 6 bits (a length <=6), 0<n<26.
Output
Output a real number to indicate the result, do not output leading 0, after the extra 0 also do not output, if it is an integer do not output a decimal point.
Input example
Sample input 10.4321 20 sample input 21.0100 12
Output example
Sample output 1.00000005148554641076956121994511276767154838481760200726351203835429763013462401 Sample output 21.126825030131969720661201
"Code":
ImportJava.util.*;Importjava.math.*;ImportJava.math.BigDecimal;ImportJava.util.*; Public classMain { Public Static voidMain (String args[]) {Scanner cin=NewScanner (system.in); DoubleA =cin.nextdouble (); intn =Cin.nextint (); BigDecimal ans=NewBigDecimal ("1"); for(inti = 0; I < n; i++) ans=ans.multiply (Bigdecimal.valueof (a)); String s=Ans.striptrailingzeros (). toplainstring (); intI=0; if(S.charat (0) = = ' 0 ' &&s.charat (1) = = '. ') I=1; for(; I<s.length (); i++) System.out.print (S.charat (i)); }}
Java
51nod 1873 Junior's Arithmetic "Java bigdecimal/high Precision decimal"