toPlainString()按一般数学表达式表示
toString()按科学型表示
replaceAll("^0", "") 如果整数里有零,替换掉
View Code
import java.util.*;
import java.math.*;
public class Main {
public static void main(String args[]){
Scanner scan=new Scanner(System.in);
while(scan.hasNext())
{
BigDecimal a=scan.nextBigDecimal();
int n=scan.nextInt();
BigDecimal ret=a.pow(n).stripTrailingZeros();//返回一个大浮点数数去掉后面的0
System.out.println(ret.toPlainString().replaceAll("^0", "") );
}
}
}