【大数问题】 HDOJ 1063 Exponentiation

实数大数~~~

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

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int n;
		String s;
		BigDecimal ans, tmp;
		while(scanner.hasNext()) {
			tmp = scanner.nextBigDecimal();
			ans = BigDecimal.ONE;
			n = scanner.nextInt();
			for(int i = 1; i <= n; i++) ans = ans.multiply(tmp);
			ans = ans.stripTrailingZeros();
			s = ans.toPlainString();
			if(s.charAt(0) == '0' ) System.out.println(s.substring(1));
			else System.out.println(s);
		}
	}
}


你可能感兴趣的:(HDU)