311303: CF1968C. Assembly via Remainders
Description
You are given an array $x_2,x_3,\dots,x_n$. Your task is to find any array $a_1,\dots,a_n$, where:
- $1\le a_i\le 10^9$ for all $1\le i\le n$.
- $x_i=a_i \bmod a_{i-1}$ for all $2\le i\le n$.
Here $c\bmod d$ denotes the remainder of the division of the integer $c$ by the integer $d$. For example $5 \bmod 2 = 1$, $72 \bmod 3 = 0$, $143 \bmod 14 = 3$.
Note that if there is more than one $a$ which satisfies the statement, you are allowed to find any.
InputThe first line contains a single integer $t$ $(1\le t\le 10^4)$ — the number of test cases.
The first line of each test case contains a single integer $n$ $(2\le n\le 500)$ — the number of elements in $a$.
The second line of each test case contains $n-1$ integers $x_2,\dots,x_n$ $(1\le x_i\le 500)$ — the elements of $x$.
It is guaranteed that the sum of values $n$ over all test cases does not exceed $2 \cdot 10^5$.
OutputFor each test case output any $a_1,\dots,a_n$ ($1 \le a_i \le 10^9$) which satisfies the statement.
ExampleInput5 4 2 4 1 3 1 1 6 4 2 5 1 2 2 500 3 1 5Output
3 5 4 9 2 5 11 5 14 16 5 11 24 501 500 2 7 5Note
In the first test case $a=[3,5,4,9]$ satisfies the conditions, because:
- $a_2\bmod a_1=5\bmod 3=2=x_2$;
- $a_3\bmod a_2=4\bmod 5=4=x_3$;
- $a_4\bmod a_3=9\bmod 4=1=x_4$;
Output
给定一个数组x[2], x[3], ..., x[n],你的任务是找到一个数组a[1], ..., a[n],满足以下条件:
1. 对于所有1≤i≤n,有1≤a[i]≤10^9。
2. 对于所有2≤i≤n,有x[i] = a[i] mod a[i-1]。
这里c mod d表示整数c除以整数d的余数。例如,5 mod 2 = 1,72 mod 3 = 0,143 mod 14 = 3。
注意,如果有多个满足条件的a数组,你可以找到其中任何一个。
输入数据格式:
第一行包含一个整数t(1≤t≤10^4)——测试用例的数量。
每个测试用例的第一行包含一个整数n(2≤n≤500)——数组a的元素数量。
每个测试用例的第二行包含n-1个整数x[2], ..., x[n](1≤x[i]≤500)——数组x的元素。
保证所有测试用例的n值之和不超过2×10^5。
输出数据格式:
对于每个测试用例,输出一个满足条件的a[1], ..., a[n](1≤a[i]≤10^9)。题目大意: 给定一个数组x[2], x[3], ..., x[n],你的任务是找到一个数组a[1], ..., a[n],满足以下条件: 1. 对于所有1≤i≤n,有1≤a[i]≤10^9。 2. 对于所有2≤i≤n,有x[i] = a[i] mod a[i-1]。 这里c mod d表示整数c除以整数d的余数。例如,5 mod 2 = 1,72 mod 3 = 0,143 mod 14 = 3。 注意,如果有多个满足条件的a数组,你可以找到其中任何一个。 输入数据格式: 第一行包含一个整数t(1≤t≤10^4)——测试用例的数量。 每个测试用例的第一行包含一个整数n(2≤n≤500)——数组a的元素数量。 每个测试用例的第二行包含n-1个整数x[2], ..., x[n](1≤x[i]≤500)——数组x的元素。 保证所有测试用例的n值之和不超过2×10^5。 输出数据格式: 对于每个测试用例,输出一个满足条件的a[1], ..., a[n](1≤a[i]≤10^9)。