POJ 1001 Exponentiation
import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { int n; BigDecimal a; Scanner in = new Scanner(System.in); while(in.hasNext()) { a = new BigDecimal(in.next()); n = in.nextInt(); a = a.pow(n); String s = a.toPlainString(); int i,j; for(i=0;;i++) if(s.charAt(i)!='0') break; for(j=s.length()-1;;j--) if(s.charAt(j)!='0') break; if(s.charAt(j)=='.') j--; System.out.println(s.substring(i, j+1)); } } }