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);
        }
    }
}

posted on 2009-12-31 20:30  ZAFU_VA  阅读(363)  评论(0编辑  收藏  举报

导航