1001 Exponentiation

 

 

import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()) {
			BigDecimal num = cin.nextBigDecimal().pow(cin.nextInt());
			String str = num.stripTrailingZeros().toPlainString();
			if(num.compareTo(BigDecimal.ONE) == -1)
				System.out.println(str.substring(1));
			else
				System.out.println(str);
		}
	}
}

你可能感兴趣的:(java,poj,1001)