1001:Exponentiation3

import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            BigDecimal decimal = scanner.nextBigDecimal();
            //OMG I love JAVA!
            int e = scanner.nextInt();
            decimal = decimal.pow(e);
            String s = decimal.stripTrailingZeros().toPlainString();
            //toPlainString:非科学记数法

            //去掉前导0
            if (s.startsWith("0."))
                System.out.println(s.substring(1));
            else
                System.out.println(s);

            if (!scanner.hasNext()) break;
        }
    }
}

你可能感兴趣的:(1001:Exponentiation3)