链接:
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 }
时间: 2024-12-28 01:27:44