CF1932B.Chaya Calendar
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The Chaya tribe believes that there are n signs of the apocalypse. Over time, it has been found out that the i-th sign occurs every ai years (in years ai, 2⋅ai, 3⋅ai, …).
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 i-th sign occurred in the year x, the tribe starts waiting for the occurrence of the (i+1)-th sign, starting from the year x+1.
In which year will the n-th sign occur and the apocalypse will happen?
查亚部落相信,世界末日有 n 个征兆。随着时间推移,人们发现第 i 个征兆每 ai 年出现一次(即在年份 ai、2⋅ai、3⋅ai、… 出现)。
根据传说,要引发末日,这些征兆必须依次出现:即先等待第一个征兆出现;在其出现之后,严格地在其之后,第二个征兆才会出现;依此类推。换言之,若第 i 个征兆出现在年份 x,则部落将从年份 x+1 开始,等待第 (i+1) 个征兆的出现。
那么,第 n 个征兆将在哪一年出现,从而导致末日降临?
输入格式
The first line of the input contains a single integer t (1≤t≤1000) — the number of test cases. Then follow the descriptions of the test cases.
The first line of each test case contains a single integer n (1≤n≤100) — the number of signs.
The second line of each test case contains n integers a1,a2,a3,…,an (1≤ai≤106) — the periodicities of the signs.
输入的第一行包含一个整数 t(1≤t≤1000),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤100),表示标志的数量。
每个测试用例的第二行包含 n 个整数 a1,a2,a3,…,an(1≤ai≤106),表示各标志的周期。
输出格式
For each test case, output a single integer — the year in which all n signs will occur.
对于每个测试用例,输出一个整数——即所有 n 个征兆同时出现的年份。
输入输出样例
输入#1
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
输出#1
36 5 5 2012
说明/提示
In the first set of input data of the example:
- The tribe will wait for the first sign in the 3-rd year;
- the tribe will wait for the second sign in the 4-th year (since year 2 have already passed);
- the tribe will wait for the third sign in the 8-th year (since the second sign has already occurred in the 4-th year);
- the tribe will wait for the fourth sign in the 10-th year (since year 5 have already passed);
- the tribe will wait for the fifth sign in the 18-th year (since year 9 have already passed);
- the tribe will wait for the sixth sign in the 36-th year (since the fifth sign has already occurred in the 18-th year).
在示例的第一组输入数据中:
- 部落将在第 3 年等待第一个征兆;
- 部落将在第 4 年等待第二个征兆(因为第 2 年已经过去);
- 部落将在第 8 年等待第三个征兆(因为第二个征兆已在第 4 年出现);
- 部落将在第 10 年等待第四个征兆(因为第 5 年已经过去);
- 部落将在第 18 年等待第五个征兆(因为第 9 年已经过去);
- 部落将在第 36 年等待第六个征兆(因为第五个征兆已在第 18 年出现)。
输入解题思路,AI测评打分。不知道怎么写?