| ||||||||||
| 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 | |||||||||
我的为什么总是超时刚开始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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator