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 |
java代码哪里错了 谁能帮忙看下import java.io.BufferedReader; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.BigInteger; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Exception{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String str; while((str=br.readLine())!=null){ String[] t=str.split(" "); String[] a=new String[2]; for(int i=0,k=0;i<t.length;i++) if(!t[i].equals("")) a[k++]=t[i]; BigDecimal b=new BigDecimal(a[0]); BigDecimal res=new BigDecimal(a[0]); int e=Integer.parseInt(a[1]); while((--e)>0){ res=res.multiply(b); } String strRes=res.toPlainString(); while((strRes.endsWith("0")&&strRes.contains("."))||strRes.endsWith(".")) strRes=strRes.substring(0,strRes.length()-1); System.out.println(strRes); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator