HDU 1063 Exponentiation

JAVA水过(注:转载)

HDU 1063 Exponentiation
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);  
        }  
    }  
}  
HDU 1063 Exponentiation

HDU 1063 Exponentiation

上一篇:深入理解abstract class和interface


下一篇:subversion