杭电 1063 Exponentiation

import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
       public static void main(String args[])
       {
    	   Scanner cin=new Scanner(System.in);
    	   int n;
    	   BigDecimal a,s;
    	   while(cin.hasNextBigDecimal())
    	   {
    		   a=cin.nextBigDecimal();
    		   n=cin.nextInt();
    		   s=BigDecimal.valueOf(1);
    		   for(int i=1;i<=n;i++)
    		   {
    			   s=s.multiply(a);
    		   }
    		   String st;
    		   st=s.stripTrailingZeros().toPlainString();
    		   if(st.charAt(0)=='0')
    		   {
    			   System.out.println(st.substring(1));
    		   }
    		   else
    		   {
    			   System.out.println(st);
    		   }
    	   }
       }
}

  

转载于:https://www.cnblogs.com/zhangshu/archive/2011/09/24/2189626.html

你可能感兴趣的:(杭电 1063 Exponentiation)