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);  

        }  

    }  

}  

 

 

你可能感兴趣的:(exp)