http://acm.hdu.edu.cn/showproblem.php?pid=1063
1 import java.math.BigDecimal;
2 import java.util.*;
3 public class Main {
4 public static void main(String []args)
5 {
6 Scanner cin=new Scanner(System.in);
7 BigDecimal r,mutil;
8 String ans;
9 int n;
10 while(cin.hasNextBigDecimal())
11 {
12 r=cin.nextBigDecimal();
13 n=cin.nextInt();
14 mutil=r.pow(n);//乘方
15 mutil=mutil.stripTrailingZeros();//去掉后导零
16 ans=mutil.toPlainString();
17 if(ans.indexOf(‘0‘)==0)
18 {
19 ans=ans.substring(1);//小于零去掉零
20 }
21 System.out.println(ans);
22 }
23 }
24
25 }
hdu 1063 Exponentiation,布布扣,bubuko.com
时间: 2024-10-25 11:33:52