UVa 748 exponentiation

Source: Internet
Author: User

+java large numbers with regular expressions It's so cool, don't you believe me? You write it in C + + and try it again.

First on the code:

Import java.math.bigdecimal;import java.util.*;import java.util.regex.*;p ublic class Main748 {public static void main ( String[] args) {Scanner scan = new Scanner (system.in); BigDecimal bd;int n;double num;while (Scan.hasnext ()) {BD = Scan.nextbigdecimal (); n = scan.nextint (); String str = BD.POW (n). toplainstring (); Pattern p = pattern.compile ("^0\\.\\d+");        Java.util.regex.Matcher m = p.matcher (str);        if (m.matches () = = true) {        str = str.substring (1);        }        int l;        For (L=str.length ()-1;; l--) {        if (Str.charat (l)! = ' 0 ') break;        }        str = str.substring (0, l+1); System.out.println (str);}}}


The topics are described as follows:


exponentiation

Problems 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 re Al number (0.0 <R < 99.999) and n is a integer such that.

Input

The input would consist of a set of pairs of values for R and n. TheR value would occupy columns 1 through 6, and the n value would be in columns 8 and 9.

Output

The output would consist of one line for each line of input giving the exact value ofRn. Leading zeros and insignificant trailing zeros should is suppressed in the output.

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

UVa 748 exponentiation

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.