import java.io.IOException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Scanner;
class Main
{
public static final boolean DEBUG = false;
public static void main(String[] args) throws IOException
{
Scanner cin;
int p, e, i, d;
int t = 1;
if (DEBUG) {
cin = new Scanner(new FileReader("d:\\OJ\\uva_in.txt"));
} else {
cin = new Scanner(new InputStreamReader(System.in));
}
while (cin.hasNext()) {
p = cin.nextInt();
e = cin.nextInt();
i = cin.nextInt();
d = cin.nextInt();
if (p == -1 && e == -1 && i == -1 && d == -1) break;
p = 23 - p % 23;
e = 28 - e % 28;
i = 33 - i % 33;
int k;
for (d++, k = 1; ; k++, d++) {
if ((p + d) % 23 == 0 && (e + d) % 28 == 0 && (i + d) % 33 == 0) {
break;
}
}
System.out.println("Case " + t++ + ": the next triple peak occurs in " + k + " days.");
}
}
}
题目1142:Biorhythms
最新推荐文章于 2021-02-22 13:29:20 发布