poj 1001 java
小数的幂计算
注意
toPlainString的使用,表示非科学计数法
View Code
1 import java.io.*;
2 import java.awt.*;
3 import java.math.*;
4 import java.text.*;
5 import java.util.*;
6
7 public class Main {
8
9 public static void main(String[] args) {
10 Scanner scan = new Scanner(new BufferedInputStream(System.in));
11 while (scan.hasNext()) {
12 BigDecimal n = scan.nextBigDecimal();
13 int d = scan.nextInt();
14 n = n.pow(d);
15 String s = new String(n.toPlainString());
16 int flag1 = 0;
17 while (s.charAt(flag1) == '0')
18 flag1++;
19 int end = s.length()-1;
20 while (s.charAt(end) == '0')
21 end--;
22 if (s.charAt(end) == '.')
23 end--;
24 for (int i = flag1; i <= end; i++)
25 System.out.print(s.charAt(i));
26 System.out.println();
27 }
28 }
29 }