hdu1063 java大实数相乘
实现小数a的b次方:
1 import java.math.BigDecimal; 2 import java.util.*; 3 import java.io.*; 4 5 public class Main { 6 public static void main(String[] args) 7 { 8 Scanner in =new Scanner(System.in); 9 while (in.hasNext()) 10 { 11 BigDecimal a=in.nextBigDecimal(); 12 int b=in.nextInt(); 13 String ans=a.pow(b).stripTrailingZeros().toPlainString(); 14 if (ans.startsWith("0")) 15 ans=ans.substring(1); 16 System.out.println(ans); 17 } 18 } 19 }
stripTrailingZeros:去掉末尾0
toPlainStrin:将科学计数法表示正常写法
startWith:去掉首位0