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

Problem 1006

Posted by Rickszyr89 at 2008-03-26 01:00:12 and last updated at 2008-03-26 01:04:12
My solution adjusts perfectly to the case study, however IT GET'S WRONG ANSWER! i've tried a few extra options myself, and it seems to work, however i still get wrong answer.... here's my code. Any ideas?

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String[] data = in.nextLine().split(" ");
		int counter = 1;
		while(!data[0].equals("-1")){
			int p = Integer.parseInt(data[0]);
			int e = Integer.parseInt(data[1]);
			int i = Integer.parseInt(data[2]);
			int d = Integer.parseInt(data[3]);
			if(p==e && e==i){
				p+=23;
				i+=33;
				e+=28;
			}
			while(p>e||e>p||p>i||i>p||i>e||e>i){
				if(p>e){
					e+=28;
				}else if (p<e) p+=23;
				if(p>i){
					i+=33;
					
				}else if (p<i) p+=23;
				if(i>e){
					e+=28;
				}else if (i<e) {
					i+=33;
					
				}
				if(i>p){
					p+=23;
				}else if (i<p) {
					i+=33;
					
				}
				if(e>p){
					p+=23;
				}else if (e<p) e+=28;
				if(e>i){
					i+=33;
				}else if (e<i) e+=28;
			}
			System.out.println("Case "+counter+": the next triple peak occurs in "+(p-d)+" days.");
			counter++;
			data=in.nextLine().split(" ");
		}
	}
}


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