304616: CF879A. Borya's Diagnosis

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Borya's Diagnosis

题意翻译

Borya要去看医生啦OvO 然而那些医生的工作时间很奇怪,可他想把n医生都看一遍。 他得到了这n个医生的信息————第一个数:Si,表示这个医生从第Si天开始才工作;第二个数:Di,表示这位医生Di天工作一次。 当然啦,Borya一天能看1个医生。 Borya想知道在第几天他能把所有医生看完 感谢@块根大佬 提供的翻译 注明:每个医生都需要前面的医生的诊断结果,所以B必须按照输入的顺序去看医生。(即:B需要先看医生1,然后看医生2,然后是医生3,以此类推) 感谢@清正美记者 提供的注明

题目描述

It seems that Borya is seriously sick. He is going visit $ n $ doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit doctor $ 1 $ , then doctor $ 2 $ , then doctor $ 3 $ and so on). Borya will get the information about his health from the last doctor. Doctors have a strange working schedule. The doctor $ i $ goes to work on the $ s_{i} $ -th day and works every $ d_{i} $ day. So, he works on days $ s_{i},s_{i}+d_{i},s_{i}+2d_{i},... $ . The doctor's appointment takes quite a long time, so Borya can not see more than one doctor per day. What is the minimum time he needs to visit all doctors?

输入输出格式

输入格式


First line contains an integer $ n $ — number of doctors ( $ 1<=n<=1000 $ ). Next $ n $ lines contain two numbers $ s_{i} $ and $ d_{i} $ ( $ 1<=s_{i},d_{i}<=1000 $ ).

输出格式


Output a single integer — the minimum day at which Borya can visit the last doctor.

输入输出样例

输入样例 #1

3
2 2
1 2
2 2

输出样例 #1

4

输入样例 #2

2
10 1
6 5

输出样例 #2

11

说明

In the first sample case, Borya can visit all doctors on days $ 2 $ , $ 3 $ and $ 4 $ . In the second sample case, Borya can visit all doctors on days $ 10 $ and $ 11 $ .

Input

题意翻译

Borya要去看医生啦OvO 然而那些医生的工作时间很奇怪,可他想把n医生都看一遍。 他得到了这n个医生的信息————第一个数:Si,表示这个医生从第Si天开始才工作;第二个数:Di,表示这位医生Di天工作一次。 当然啦,Borya一天能看1个医生。 Borya想知道在第几天他能把所有医生看完 感谢@块根大佬 提供的翻译 注明:每个医生都需要前面的医生的诊断结果,所以B必须按照输入的顺序去看医生。(即:B需要先看医生1,然后看医生2,然后是医生3,以此类推) 感谢@清正美记者 提供的注明

加入题单

上一题 下一题 算法标签: