hdu 1063 Exponentiation

求实数的幂,这个用C++写的话有点长,但是用Java写就非常方便了……

import java.io.*;
import
java.math.*;
import
java.util.*;
import
java.text.*;

public class
Main
{

    public static
void main(String arg[]){
        Scanner
cin=new Scanner(System.in);
        String
an;
        while
(cin.hasNextDouble())
        {

            BigDecimal
ans = cin.nextBigDecimal();
            int
n=cin.nextInt();
            ans=ans.pow(n).stripTrailingZeros();
            an=ans.toPlainString();
            if
(an.charAt(0)=='0')
                an=an.substring(1);
            System
.out.println(an);
        }
    }
}

posted @ 2013-07-20 21:28  _随心所欲_  阅读(110)  评论(0编辑  收藏  举报