#P6484. [COCI 2010/2011 #4] ASTRO
[COCI 2010/2011 #4] ASTRO
Description
There are two stars. Each of them flashes once every fixed period of time.
Now you are given the time when each star flashes for the first time, and the interval between two flashes for each star. You need to find on which day and at what time the two stars flash simultaneously for the first time.
Note: the day when the flashing starts is Saturday, and 00:00 is the first minute of a day.
Input Format
The input consists of four lines.
Each line contains a time in the form HH:MM (hours:minutes), in order: the initial flashing time of the first star; the initial flashing time of the second star; the flashing interval of the first star; the flashing interval of the second star.
It is guaranteed that the times in the first two lines are different and both are on Saturday; the intervals will not be 00:00.
Output Format
If the two stars will never flash at the same time, output Never.
Otherwise output two lines. The first line is a string indicating the day of the week when they first flash simultaneously. The second line is a time in the same format as the input, indicating the exact time of that simultaneous flash on that day.
Correct spellings of the words (from Sunday to Saturday) are:
Sunday Monday Tuesday Wednesday Thursday Friday Saturday.
If , you need to output a leading .
02:20
13:00
05:50
01:00
Saturday
14:00
02:20
23:28
00:40
23:50
Never
23:19
10:19
02:42
09:11
Thursday
00:31
Hint
Constraints
- For of the testdata, the interval is an integer number of hours, i.e. ; for example,
13:00. - For of the testdata, , .
Notes
Translated from COCI2010-2011 CONTEST #4 T3 ASTRO。
Translated by ChatGPT 5
京公网安备 11011102002149号