poj1001

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


public class poj1001 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(new BufferedInputStream(System.in));
        BigDecimal a,s;
        int p;
        while(cin.hasNext()) {
            a=cin.nextBigDecimal();
            p=cin.nextInt();
            s=BigDecimal.valueOf(1);
            for(int i=1;i<=p;++i) {
                s=s.multiply(a);
            }
            s=s.stripTrailingZeros();

            if(s.compareTo(BigDecimal.valueOf(1))<0) {
                String ans=s.toPlainString();
                for(int i=1;i!=ans.length();++i) {
                    System.out.print(ans.charAt(i));
                }
                System.out.println();
            }
            else {
                String ans=s.toPlainString();
                System.out.println(ans);
            }

        }

    }
}

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