| ||||||||||
| 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 | |||||||||
Problem 1006My 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator