hdu 1063 Exponentiation java

import java.io.*;

import java.math.*;
import
java.util.*;
/**
*
* @author va
*/
public class
Main {

    /**
     * @param args the command line arguments
     */
    public static
void main(String[] args) {
        // TODO code application logic here
        Scanner cin = new Scanner(System.in);
        BigDecimal
a;
        int
n;
        while
(cin.hasNextBigDecimal())
        {

            a = cin.nextBigDecimal();
            n = cin.nextInt();
            int
i;
            BigDecimal
b = new BigDecimal("1");
            for
(i = 0; i < n; ++i)
            {

                b = b.multiply(a);
            }

            b = b.stripTrailingZeros();
            String
str = b.toPlainString();
            if
(str.startsWith("0."))

    {
                str = str.substring(1);

    }
            System.out.println(str);
        }
    }
}

你可能感兴趣的:(hdu 1063 Exponentiation java)