# CF879A Borya's Diagnosis

• 144通过
• 294提交
• 题目来源
• 评测方式 RemoteJudge
• 标签
• 难度 入门难度
• 时空限制 2000ms / 256MB
• 提示：收藏到任务计划后，可在首页查看。

## 题意翻译

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$ .

提示
标程仅供做题后或实在无思路时参考。
请自觉、自律地使用该功能并请对自己的学习负责。
如果发现恶意抄袭标程，将按照I类违反进行处理。