题目:http://acm.pku.edu.cn/JudgeOnline/problem?id=1006
- 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++;
- int next = 0;
- while ((d + next - p) % 23 != 0 || (d + next - e) % 28 != 0
- || (d + next - i) % 33 != 0) {
- next++;
- }
- if (next > 21252) {
- next = 21252;
- }
- if (next == 0) {
- next = 21252;
- }
- System.out.println("Case " + cases
- + ": the next triple peak occurs in " + next + " days.");
- }
- }
- }