#P3409. 值日班长值周班长
值日班长值周班长
Description
In a semester, there are daily duty monitors (值日班长), where A is the -th daily duty monitor, and there are weekly duty monitors (值周班长), where B is the -th weekly duty monitor. Assume we ignore holidays and any other schedule changes, and the daily/weekly duty rotations are never rearranged; that is, every week always has school days and rest days, and this semester never ends. On which day of the semester will it first happen that A is the daily duty monitor and B is the weekly duty monitor at the same time? If it never happens, output Orz mgh!!!.
Input Format
Multiple test cases. Each test case consists of one line with four integers . It is guaranteed that and .
Output Format
For each test case, output one line with the result.
20 7 3 3
30 7 4 3
27
Orz mgh!!!
Hint
| Test point ID | Number of test cases | Special property | ||
|---|---|---|---|---|
| 1 | Yes | |||
| 2 | No | |||
| 3 | ||||
| 4 | Yes | |||
| 5 | No | |||
| 6 | ||||
| 7 | ||||
| 8 | Yes | |||
| 9 | ||||
| 10 | No | |||
Special property: is a multiple of .
For of the testdata, , , and the number of test cases does not exceed . Note that the maximum number of test cases and the maximum values of and will not be reached at the same time.
Translated by ChatGPT 5
京公网安备 11011102002149号