QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#1783. 蝗虫轨迹

Statistics

有两种不同种类的周期性蝉,它们分别每 13 年和 17 年从冬眠中出现一次。你的爷爷告诉你,他在 1992 年同时看到了它们。你开始思考还要等多少年才能再次见到它们。你收集了关于其他几对周期性蝉的信息以及它们上一次被观察到的时间,以找出下一次同时出现的时间。

给定几对不同的蝉以及它们上一次同时出现的年份,找出其中任意一对蝉再次同时出现的年份中的最小值。

输入格式

输入的第一行包含一个整数 $k$ ($1 \le k \le 99$),表示周期性蝉的对数。接下来有 $k$ 行,每行包含三个整数 $y$、$c_1$ 和 $c_2$ ($1800 \le y \le 2021$,$1 \le c_1, c_2 \le 99$),分别表示该对蝉上一次同时出现的年份,以及第一种和第二种蝉的周期长度。你可以假设这 $k$ 对蝉都不会在 2022 年之前再次出现。

输出格式

输出任意一对蝉再次同时出现的年份中的最小值。

样例

样例输入 1

3
1992 13 17
1992 14 18
2001 5 7

样例输出 1

2036

样例输入 2

2
2020 2 3
2019 3 4

样例输出 2

2026

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.