시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 241 | 140 | 123 | 59.135% |
You recently missed an eclipse and are waiting for the next one! To see any eclipse from your home, the sun and the moon must be in alignment at specific positions. You know how many years ago the sun was in the right position, and how many years it takes for it to get back to that position. You know the same for the moon. When will you see the next eclipse?
The input consists of two lines.
The first line contains two integers, $d_s$ and $y_s$ $(0 \le d_s < y_s \le 50)$, where $d_s$ is how many years ago the sun was in the right position, and $y_s$ is how many years it takes for the sun to be back in that position.
The second line contains two integers, $d_m$ and $y_m$ $(0 \le d_m < y_m \le 50)$, where $d_m$ is how many years ago the moon was in the right position, and $y_m$ is how many years it takes for the moon to be back in that position.
Output a single integer, the number of years until the next eclipse. The data will be set in such a way that there is not an eclipse happening right now and there will be an eclipse within the next $5\,000$ years.
3 10 1 2
7
ICPC > Regionals > North America > Mid-Atlantic Regional > 2022 Mid-Atlantic USA Regional Contest > Division 2 H번
ICPC > Regionals > North America > South Central USA Regional > 2022 South Central USA Regional Contest > Division 2 H번
ICPC > Regionals > North America > Southeast USA Regional > 2022 Southeast USA Regional Programming Contest > Division 2 H번
ICPC > Regionals > North America > North Central North America Regional > 2022 North Central NA Regional Contest E번
ICPC > Regionals > North America > Pacific Northwest Regional > 2022 ICPC Pacific Northwest Region > Division 1 J번
ICPC > Regionals > North America > Pacific Northwest Regional > 2022 ICPC Pacific Northwest Region > Division 2 J번
ICPC > Regionals > North America > Rocky Mountain Regional > 2022 Rocky Mountain Regional Contest J번