High precision Power (Java)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.