CF1932B.Chaya Calendar

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Chaya tribe believes that there are nn signs of the apocalypse. Over time, it has been found out that the ii -th sign occurs every aia_i years (in years aia_i , 2ai2 \cdot a_i , 3ai3 \cdot a_i , \dots ).

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 ii -th sign occurred in the year xx , the tribe starts waiting for the occurrence of the (i+1)(i+1) -th sign, starting from the year x+1x+1 .

In which year will the nn -th sign occur and the apocalypse will happen?

输入格式

The first line of the input contains a single integer tt ( 1t10001 \le t \le 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 nn ( 1n1001 \le n \le 100 ) — the number of signs.

The second line of each test case contains nn integers a1,a2,a3,,ana_1, a_2, a_3, \dots, a_n ( 1ai1061 \le a_i \le 10^6 ) — the periodicities of the signs.

输出格式

For each test case, output a single integer — the year in which all nn signs will occur.

输入输出样例

  • 输入#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 33 -rd year;
  • the tribe will wait for the second sign in the 44 -th year (since year 22 have already passed);
  • the tribe will wait for the third sign in the 88 -th year (since the second sign has already occurred in the 44 -th year);
  • the tribe will wait for the fourth sign in the 1010 -th year (since year 55 have already passed);
  • the tribe will wait for the fifth sign in the 1818 -th year (since year 99 have already passed);
  • the tribe will wait for the sixth sign in the 3636 -th year (since the fifth sign has already occurred in the 1818 -th year).
首页