#347. Biorhythms

Biorhythms

题目描述

人有三个生理周期:体力周期(2323 天)、感情周期(2828 天)和智力周期(3333 天),每个周期有一天是高峰。已知从当年第一天到三个高峰日的天数 p,e,ip, e, i,以及一个给定的起始天数 dd,求从 dd 之后(不包含 dd 当天)下一次三个高峰落在同一天所需的天数。

输入格式

输入多组数据,每组一行四个整数 p,e,i,dp, e, i, d
p=e=i=d=1p = e = i = d = -1 时输入结束。

输出格式

对于每组数据,输出一行,格式为:
Case 编号: the next triple peak occurs in 天数 days.

0 0 0 0
0 0 0 100
5 20 34 325
4 5 6 7
283 102 23 320
203 301 203 40
-1 -1 -1 -1
Case 1: the next triple peak occurs in 21252 days.
Case 2: the next triple peak occurs in 21152 days.
Case 3: the next triple peak occurs in 19575 days.
Case 4: the next triple peak occurs in 16994 days.
Case 5: the next triple peak occurs in 8910 days.
Case 6: the next triple peak occurs in 10789 days.

数据规模与约定

对于全部的测试数据:

  • 0p,e,i,d<3650 \leq p, e, i, d < 365
  • 答案天数小于 2125221252