码迷,mamicode.com
首页 > 其他好文 > 详细

POJ 1001 高精度

时间:2017-05-05 18:32:55      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:imp   rgs   tar   ble   span   href   system   port   scan   

链接:

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 }

POJ 1001 高精度

标签:imp   rgs   tar   ble   span   href   system   port   scan   

原文地址:http://www.cnblogs.com/baocong/p/6814155.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!