HDU 1063大数求幂运算
View Code
1 import java.util.*; 2 import java.math.*; 3 import java.io.*; 4 5 public class Hdu1063{//提交时名字改为Main 6 public static void main(String args[]){ 7 int n; 8 BigDecimal R,res; 9 String str; 10 Scanner cin = new Scanner(System.in); 11 12 while(cin.hasNext()){ 13 R = cin.nextBigDecimal(); 14 n = cin.nextInt(); 15 res = R.pow(n); 16 17 str = res.stripTrailingZeros().toPlainString(); 18 if(str.charAt(0) == '0') 19 System.out.println(str.substring(1)); 20 else 21 System.out.println(str); 22 } 23 24 } 25 }