50,538
社区成员
发帖
与我相关
我的任务
分享
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int p = -1;
int e, i, d;
int cases = 0;
while (true) {
p = scan.nextInt();
e = scan.nextInt();
i = scan.nextInt();
d = scan.nextInt();
if (p == -1 && e == -1 && i == -1 && d == -1) {
return;
}
cases++;
p+=23;
e+=28;
i+=33;
while(true){
if(p<e||p<i)
p+=23;
if(e<p||e<i)
e+=28;
if(i<e||i<p)
i+=33;
if(p==e&&e==i){
break;
}
}
if (e > 21252) {
e = 21252;
}
if (e == 0) {
e = 21252;
}
System.out.println("Case " + cases
+ ": the next triple peak occurs in " + (e-d) + " days.");
}
}
}