Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
贴一份代码,感觉自己写的好搓,看来我注定是ds程序员的命import java.io.PrintWriter; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { static Scanner cin = new Scanner(System.in); static PrintWriter cout = new PrintWriter(System.out,true); public static void main(String[] args) { while(cin.hasNext()) { double a= cin.nextDouble(); int n=cin.nextInt(); doJob(a,n); } } private static void doJob(double a,int n) { BigDecimal x= new BigDecimal(String.valueOf(a)); //x.setScale(100); BigDecimal sum=new BigDecimal("1"); for(int i = 1; i<=n;i++) { sum = sum.multiply(x); } String output = sum.stripTrailingZeros().toPlainString(); if(output.startsWith("0")) { output = output.substring(1); } cout.println(output); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator