HDU 1063 Exponentiation

JAVA水过(注:转载)

import java.math.BigDecimal;  
import java.math.BigInteger;  
import java.util.Scanner;  
public class Main {  
    public static void main(String[] args) {  
        new Main();  
    }  
    public Main(){  
        BigDecimal r;  
        int n;  
        Scanner sc=new Scanner(System.in);  
        while(sc.hasNext()){  
            r=sc.nextBigDecimal();  
            n=sc.nextInt();  
                        //去末尾0,转成字符串  
            String st=r.pow(n).stripTrailingZeros().toPlainString();  
            int ind=0;  
            while(true){  
                if(st.charAt(ind)!='0')break;  
                ind++;  
            }  
            st=st.substring(ind);  
            System.out.println(st);  
        }  
    }  
}  

 

 

posted @ 2014-01-18 15:20  forever97  阅读(135)  评论(0编辑  收藏  举报