POJ 1001 高精度

链接:

http://poj.org/problem?id=1001

题意:

计算小数的幂,高精度

题解:

第一次用 java ac,^-^

代码:

 1 import java.util.*;
 2 import java.math.*;
 3 
 4 public class Main {
 5     public static void main(String args[]) {
 6         Scanner cin = new Scanner(System.in);
 7         while (cin.hasNext()) {
 8             String a = cin.next();
 9             int t = cin.nextInt();
10             BigDecimal ans = new BigDecimal(a);
11             ans = ans.pow(t);
12             String res = ans.stripTrailingZeros().toPlainString();
13             if (res.charAt(0) == '0') res = res.substring(1);
14             System.out.println(res);
15         }
16     }
17 }
posted @ 2017-05-05 17:36  Flowersea  阅读(123)  评论(0编辑  收藏  举报