题意:求高精度幂。
解决本题时使用了Java中提供的BigDecimal类(Java.math.BigDecimal),计算幂随后调用其中toPlainString返回求出结果的字符串形式,通过设置sta和end去掉前导0和后缀0
import java.util.*;
import java.math.*;
public class Main{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
BigDecimal r;
int n;
while(in.hasNext()){
r = in.nextBigDecimal();
n = in.nextInt();
r = r.pow(n);
String st = new String(r.toPlainString());
int sta = 0;
while(st.charAt(sta) == '0') sta++;
int end = st.length() - 1;
while(st.charAt(end) == '0') end--;
if(st.charAt(end) == '.') end--;
for(int i = sta; i <= end; i++)
System.out.print(st.charAt(i));
System.out.println();
}
}
}