欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1932B.Chaya Calendar
Chaya Calendar
The Chaya tribe believes that there are signs of the apocalypse. Over time, it has been found out that the -th sign occurs every years (in years , , , ).
According to the legends, for the apocalypse to happen, the signs must occur sequentially. That is, first they wait for the first sign to occur, then strictly after it, the second sign will occur, and so on. That is, if the -th sign occurred in the year , the tribe starts waiting for the occurrence of the -th sign, starting from the year .
In which year will the -th sign occur and the apocalypse will happen?
Input
The first line of the input contains a single integer () — the number of test cases. Then follow the descriptions of the test cases.
The first line of each test case contains a single integer () — the number of signs.
The second line of each test case contains integers () — the periodicities of the signs.
Output
For each test case, output a single integer — the year in which all signs will occur.
Note
In the first set of input data of the example:
- The tribe will wait for the first sign in the -rd year;
- the tribe will wait for the second sign in the -th year (since year have already passed);
- the tribe will wait for the third sign in the -th year (since the second sign has already occurred in the -th year);
- the tribe will wait for the fourth sign in the -th year (since year have already passed);
- the tribe will wait for the fifth sign in the -th year (since year have already passed);
- the tribe will wait for the sixth sign in the -th year (since the fifth sign has already occurred in the -th year).
Samples
4
6
3 2 4 5 9 18
5
1 2 3 4 5
5
1 1 1 1 1
6
50 30 711 200 503 1006
36
5
5
2012
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |