Description: Humans are born with three cycles of physical, emotional, and intellectual cycles, with periods of 23 days, 28 days and 33 days. One day in each cycle is a peak. At the peak of the day, people will do well in the corresponding aspects. For example, the peak of the intellectual cycle, people will be quick thinking, energy is easy to highly concentrated. Because the circumference of the three cycles is different, the peak of three cycles usually does not fall on the same day. For everyone, we want to know when three peaks fall on the same day. For each cycle, we will give the number of days from the first day of the current year to the peak (not necessarily the time of the first peak). Your task is to give a number of days from the first day of the year, and the output starts from a given time (excluding a given time) the next three peaks fall on the same date (the number of days from a given time). For example: Given a time of 10, the next occurrence of three peaks on the same day is 12, then output 2 (note that this is not 3).
Input: Enter four integers: p, E, I, and D. P, E, I, respectively, indicate the time at which the physical, emotional and intellectual peaks appear (the time is calculated from the first day of the year). D is the given time, which may be less than P, E, or I. All given time is nonnegative and less than 365, the time required is less than or equal to 21252.
Output: From a given time, the next three peaks of the same day (the number of days from a given time).
Input
0 0 0 00 0 0 1005 20 34 3254 5 6 7283 102 23 320203 301 203 40-1-1-1-1
Output
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.
1#include <iostream>2 using namespacestd;3 4 intCalintPintEintIintd)5 {6 for(intj =1;; J + +)7 {8 if((j-p)% at==0&& (J-E)% -==0&& (j-i)% -==0)9 returnJ-D;Ten } One } A intMain () - { - intP, E, I, d, n =0; the while(CIN >> P >> e >> i >> D) && (P! =EOF)) - { -n++; -cout <<" Case"<< N <<": The next triple peak occurs in"<< cal (P, E, I, D) <<"Days ."<<Endl; + } -System"Pause"); + return 0; A}
Physiological cycle (c + + implementation)