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

为什么会RunTimeError啊?难道判断文件结束有问题?

Posted by kensinjava at 2005-08-08 00:41:10 on Problem 2539
import java.io.*;
import java.math.BigDecimal;
import java.util.StringTokenizer;
public class Main
{
	public static void main(String args[]) throws Exception
	{
		String s;
		BigDecimal m,n,t;
		int i,j,k;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.flush();
		s = br.readLine();
		while(s!=null)
		{
			StringTokenizer a = new StringTokenizer(s);
			s = a.nextToken();
			m = new BigDecimal(s);
			k = Integer.parseInt(s);
			i = Integer.parseInt(a.nextToken());
			j = Integer.parseInt(a.nextToken());
			System.out.print("("+m+"^"+i+"-1)/("+m+"^"+j+"-1) ");
			if((i-j)*Math.log(k)/Math.log(10)<102)
			{
			n = m.pow(i).subtract(new BigDecimal("1"));
			t = m.pow(j).subtract(new BigDecimal("1"));
			m = n.divide(t,0);
			if(m.multiply(t).equals(n))
			{
			if(m.toPlainString().length()>=100)
			System.out.println("is not an integer with less than 100 digits.");
			else
			System.out.println(m);
		}
		else
		System.out.println("is not an integer with less than 100 digits.");
		}
	else
		System.out.println("is not an integer with less than 100 digits.");
		System.out.flush();
		s = br.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