Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这个程序有什么问题,一直wa,我晕死了-_-

Posted by hetao at 2004-12-02 08:14:29 on Problem 1001
import java.io.*;
import java.util.*;
import java.math.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
	BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
	String line = stdin.readLine();
	BigDecimal r;
	while(line!=null){
	    StringTokenizer st = new StringTokenizer(line);
	    //if(!st.hasMoreTokens())continue;
	    r=new BigDecimal(st.nextToken());
	    int p=Integer.parseInt(st.nextToken());
	    String s=
	    	new BigDecimal(r.movePointRight(10).toBigInteger().pow(p)).movePointLeft(10*p).toString();
	    int i,j;
	    for(i=0;i<s.length();++i)
		if(s.charAt(i)!='0')break;
	    for(j=s.length()-1;j>=0;--j)
		if(s.charAt(j)!='0')break;
	    if(s.charAt(j)=='.')--j;
	    System.out.println(s.substring(i,j+1));
	    line=stdin.readLine();
	
	}
    }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator