| ||||||||||
| 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 | |||||||||
I'm afraid there are more than 50 groups of test data.In Reply To:服务器是用什么方法测试程序的呢,为啥在我机器运行都好使,一传上来就Runtime error呢 Posted by:gostopsb at 2006-11-10 22:41:56 > 1006的JAVA代码,高手帮帮我啊
>
> import java.util.*;
>
> public class Biorhythms
> {
> public static int nextPeak(int p, int e, int in)
> {
> int result = 0;
>
> for (int i = in; i <= 21252; i = i + 33)
> {
> if ((i - p) % 23 == 0 && (i - e) % 28 == 0 && (i - in) % 33 == 0)
> {
> if(p==0&&e==0&&in==0)
> {
> return 21252;
> }
> result = i;
> return result;
> }
> }
> return result;
> }
>
> public static void main(String args[])
> {
> Scanner sc = new Scanner(System.in);
>
> int p = sc.nextInt();
> int e = sc.nextInt();
> int in = sc.nextInt();
> int day = sc.nextInt();
>
> int count = 1;
> int[] result = new int[50];
> while (!(p == -1 && e == -1 && in == -1 && day == -1))
> {
>
> result[count] = nextPeak(p, e, in) - day;
> count++;
>
> p = sc.nextInt();
> e = sc.nextInt();
> in = sc.nextInt();
> day = sc.nextInt();
> }
>
> for (int i = 1; i < count; i++)
> {
> System.out.println("Case " + i
> + ": the next triple peak occurs in " + result[i]
> + " days.");
> }
> }
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator