Power of High Precision
| Time limit:500 ms |
|
Memory limit:10000 K |
| Total submissions:117394 |
|
Accepted:28569 |
Description
It is a very common problem to perform high-precision calculation on numbers with large numbers and high precision. For example, calculating national debt is a problem of this type.
The problem you want to solve now is: for a real number R (0.0 <r <99.999), The Write Program is required to accurately calculate the N power (RN) of R ), where N is an integer and 0 <n <= 25.
Input
T input includes multiple groups of R and N. The R value accounts for 1st to 6th columns, and the N value accounts for 8th and 9th columns.
Output
For each group of input, a row must be output, and the row contains the exact Nth Power of R. The output must be removed from the leading 0 and not 0. If the output is an integer, do not output the decimal point.
Sample Input
95.123 120.4321 205.1234 156.7592 998.999 101.0100 12
Sample output
548815620517731830194541.899025343415715973535967221869852721.0000000514855464107695612199451127676715483848176020072635120383542976301346240143992025569.92857370126648804114665499331870370751166629547672049395302429448126.76412102161816443020690903717327667290429072743629540498.1075960194566517745610440100011.126825030131969720661201
Source
East central North America 1988
Translator
Program Design Practice at Peking University, Xie di
| 1001 |
Accepted |
3344 K |
141 Ms |
Java |
459b |
03:02:02 |
Import Java. util. *; import Java. math. *; public class main {public static void main (string ARGs []) {program CIN = new program (system. in); bigdecimal R; int N; string s; while (CIN. hasnextbigdecimal () {r = cin. nextbigdecimal (); n = cin. nextint (); r = R. pow (n); s = R. striptrailingzeros (). toplainstring (); // avoid scientific notation if (S. startswith ("0") S = S. substring (1); // remove the leading 0 system before the decimal point. out. println (s );}}}