CF2195D.Absolute Cinema
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a hidden sequence a1,a2,…,an of n integers (n≥2). It is guaranteed that ∣ai∣≤1000 for all 1≤i≤n.
Let's define a function f(x) as follows:
f(x)=sum_i=1na_icdot∣i−x∣
Given n values f(1),f(2),…,f(n), please determine the values of a1,a2,…,an.
It is guaranteed that the values a1,a2,…,an can be determined uniquely.
存在一个隐藏的整数序列 a1,a2,…,an(其中 n≥2)。保证对所有 1≤i≤n,均有 ∣ai∣≤1000。
我们定义函数 f(x) 如下:
f(x)=i=1∑nai⋅∣i−x∣
给定 n 个值 f(1),f(2),…,f(n),请确定 a1,a2,…,an 的值。
保证 a1,a2,…,an 的值可被唯一确定。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains a single integer n (2≤n≤300000).
The second line of each test case contains n integers f(1),f(2),…,f(n) (−1014≤f(i)≤1014).
It is guaranteed that the sum of n over all test cases does not exceed 300000.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(2≤n≤300000)。
每个测试用例的第二行包含 n 个整数 f(1),f(2),…,f(n)(−1014≤f(i)≤1014)。
保证所有测试用例的 n 之和不超过 300000。
输出格式
For each test case, output n integers a1,a2,…,an on a separate line (∣ai∣≤1000).
It is guaranteed that the values a1,a2,…,an can be determined uniquely.
对于每个测试用例,在单独一行中输出 n 个整数 a1,a2,…,an(满足 ∣ai∣≤1000)。
保证 a1,a2,…,an 的值可以被唯一确定。
输入输出样例
输入#1
4 4 17 9 9 13 6 -37 -32 -15 4 27 42 5 -26 -32 -24 -4 2 2 420 -69
输出#1
1 4 2 3 3 6 1 2 -4 -7 -6 7 6 -7 -6 -69 420
说明/提示
In the first test case, the hidden sequence is a=[1,4,2,3].
The values f(1),f(2),…,f(n) are as follows:
- f(1)=1⋅∣1−1∣+4⋅∣2−1∣+2⋅∣3−1∣+3⋅∣4−1∣=0+4+4+9=17;
- f(2)=1⋅∣1−2∣+4⋅∣2−2∣+2⋅∣3−2∣+3⋅∣4−2∣=1+0+2+6=9;
- f(3)=1⋅∣1−3∣+4⋅∣2−3∣+2⋅∣3−3∣+3⋅∣4−3∣=2+4+0+3=9;
- f(4)=1⋅∣1−4∣+4⋅∣2−4∣+2⋅∣3−4∣+3⋅∣4−4∣=3+8+2+0=13.
在第一个测试用例中,隐藏序列为 a=[1,4,2,3]。
函数值 f(1),f(2),…,f(n) 如下:
- f(1)=1⋅∣1−1∣+4⋅∣2−1∣+2⋅∣3−1∣+3⋅∣4−1∣=0+4+4+9=17;
- f(2)=1⋅∣1−2∣+4⋅∣2−2∣+2⋅∣3−2∣+3⋅∣4−2∣=1+0+2+6=9;
- f(3)=1⋅∣1−3∣+4⋅∣2−3∣+2⋅∣3−3∣+3⋅∣4−3∣=2+4+0+3=9;
- f(4)=1⋅∣1−4∣+4⋅∣2−4∣+2⋅∣3−4∣+3⋅∣4−4∣=3+8+2+0=13。
输入解题思路,AI测评打分。不知道怎么写?