포럼
문제 ICPC00284

L. Locust Locus

설명

There are two different species of periodical cicadas that only appear from hibernation every \(13\) and \(17\) years, respectively. Your old grandpa tells you that he saw them simultaneously back in '92. You start pondering how many years you have to wait until you see them again. You collect information about other pairs of periodical cicadas and when they were last observed to find out when the next simultaneous appearance is.

Given several different pairs of cicadas and their last simultaneous appearance, find the next year that one of the pairs reappears.

제약
입력 형식

The first line of input contains a single integer \(k\) (\(1 \le k \le 99\)), the number of pairs of periodical cicadas. Then follow \(k\) lines, each containing three integers \(y\), \(c_1\) and \(c_2\) (\(1800 \le y \le 2021\), \(1 \le c_1, c_2 \le 99\)), the year this pair was last observed and cycle lengths for the first and second species, respectively. You may assume that none of the \(k\) pairs reappears earlier than \(2022\).

출력 형식

Output the first year a pair reappears.

예제 1
입력
3
1992 13 17
1992 14 18
2001 5 7
출력
2036
예제 2
입력
2
2020 2 3
2019 3 4
출력
2026
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2021

평가 및 의견

L. Locust Locus

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

L. Locust Locus

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8