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 |
PKU用的是JDK1.5,1.5里BigDecimal的toString()和1.4的返回值不一样,查一下API手册吧In Reply To:高手给我看看吧!吧! Posted by:qinbill at 2005-05-24 09:57:00 > import java.io.BufferedReader; > import java.io.InputStreamReader; > import java.math.BigDecimal; > import java.util.StringTokenizer; > > public class Main > { > public static void main (String args[]) throws Exception > { > BigDecimal big,result,one; > int k; > byte[] rebyte; > one=new BigDecimal("1"); > String line; > BufferedReader stdin = > new BufferedReader( > new InputStreamReader(System.in)); > while(true) > { > line=stdin.readLine(); > if(line==null) break; > StringTokenizer st = new StringTokenizer(line); > String a = (st.nextToken()); > int b = Integer.parseInt(st.nextToken()); > big = new BigDecimal(a); > result=new BigDecimal("1"); > for(int i=0;i<b;i++) > result=result.multiply(big); > String re=result.toString(); > rebyte=re.getBytes(); > for(int i=0;i<rebyte.length;i++) > rebyte[i]-=48; > int i=0; > while(rebyte[i]==0) > { > rebyte[i++]=-1; > } > i=rebyte.length-1; > while(rebyte[i]==0) > { > rebyte[i--]=-1; > } > if(rebyte[i]==-2) > rebyte[i]=-1; > for(i=0;i<rebyte.length;i++) > { > if(rebyte[i]==-2) > { > System.out.print('.'); > }else if(rebyte[i]==-1) > { > }else > { > System.out.print(rebyte[i]); > } > } > System.out.println(); > > } > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator