POJ1006

 题目:http://acm.pku.edu.cn/JudgeOnline/problem?id=1006

 

  1. import java.util.Scanner;
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Scanner scan = new Scanner(System.in);
  5.         int p = -1;
  6.         int e, i, d;
  7.         int cases = 0;
  8.         while (true) {
  9.             p = scan.nextInt();
  10.             e = scan.nextInt();
  11.             i = scan.nextInt();
  12.             d = scan.nextInt();
  13.             if (p == -1 && e == -1 && i == -1 && d == -1) {
  14.                 return;
  15.             }
  16.             cases++;
  17.             int next = 0;
  18.             while ((d + next - p) % 23 != 0 || (d + next - e) % 28 != 0
  19.                     || (d + next - i) % 33 != 0) {
  20.                 next++;
  21.             }
  22.             if (next > 21252) {
  23.                 next = 21252;
  24.             }
  25.             if (next == 0) {
  26.                 next = 21252;
  27.             }
  28.             System.out.println("Case " + cases
  29.                     + ": the next triple peak occurs in " + next + " days.");
  30.         }
  31.     }
  32. }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值