Logo
(追記) (追記ここまで)

32854번 - Traffic Lights 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB93633563.636%

문제

You are staring down a street with $n$ traffic lights. Each traffic light has been set to alternate its color between $r$ seconds of red and $g$ seconds of green based on the two duration parameters $r$ and $g$. These two parameters may vary across different traffic lights.

You saw that all the traffic lights had been green, but had just all turned red at the same time. You are wondering how many seconds it would take before the traffic lights are all green again.

입력

The first line of input contains a single integer $n$ (1ドル ≤ n ≤ 10$), the number of traffic lights.

The next n lines each contain two integers $r$ and $g$ (1ドル ≤ r, g ≤ 10$), giving the number of seconds that a traffic light stays red and green respectively.

출력

Output a single integer, the earliest time that the lights are all green again. If this will never happen, output $-1$.

제한

예제 입력 1

3
2 4
3 1
6 1

예제 출력 1

27

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2024 Southeast USA Regional Programming Contest > Division 2 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /