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

我的为什么总是超时

Posted by wang198839 at 2009-07-04 12:35:14 on Problem 1006
刚开始r1,r2,r3的计算也写在代码里了,提交了超时,就直接把r1,r2,r3算出来了,再提交还是超时,想不出哪里的问题了。我是新手,希望大家帮忙看一下。
import java.util.Scanner;

public class Main {
	int p, e, i, d;

	int r1 = 5544, r2 = 14421, r3 = 1288;

	int next, n;

	public Main() {
		Scanner scanner = new Scanner(System.in);
		n = 1;
		p = scanner.nextInt();
		e = scanner.nextInt();
		i = scanner.nextInt();
		d = scanner.nextInt();

		while (p != -1) {
			next = (r1 * p + r2 * e + r3 * i - d + 21252) % 21252;
			if (next == 0)
				next = 21252;

			System.out.printf(
					"Case %d: the next triple peak occurs in %d days.\n", n++,
					next);
			p = scanner.nextInt();
			e = scanner.nextInt();
			i = scanner.nextInt();
			d = scanner.nextInt();
		}
	}

	public static void main(String[] args) {
		new Main();
	}
}

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