欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1153A.Serval and Bus
Serval and Bus
It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for this poor little boy is to wait for a bus on this rainy day. Under such circumstances, the poor boy will use the first bus he sees no matter where it goes. If several buses come at the same time, he will choose one randomly.
Serval will go to the bus station at time , and there are bus routes which stop at this station. For the -th bus route, the first bus arrives at time minutes, and each bus of this route comes minutes later than the previous one.
As Serval's best friend, you wonder which bus route will he get on. If several buses arrive at the same time, you can print any of them.
Input
The first line contains two space-separated integers and (, ) — the number of bus routes and the time Serval goes to the station.
Each of the next lines contains two space-separated integers and () — the time when the first bus of this route arrives and the interval between two buses of this route.
Output
Print one number — what bus route Serval will use. If there are several possible answers, you can print any of them.
Note
In the first example, the first bus of the first route arrives at time , and the first bus of the second route arrives at time , so the first route is the answer.
In the second example, a bus of the third route arrives at time , so it is the answer.
In the third example, buses of the first route come at times , , , , and so fourth, buses of the second route come at times , , , and so fourth and buses of the third route come at times , , , and so on, so and are both acceptable answers while is not.
Samples
2 2
6 4
9 5
1
5 5
3 3
2 5
5 6
4 9
6 1
3
3 7
2 2
2 3
2 4
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |