CF1857E Power of Points
Description
You are given $ n $ points with integer coordinates $ x_1,\dots x_n $ , which lie on a number line.
For some integer $ s $ , we construct segments \[ $ s,x_1 $ \], \[ $ s,x_2 $ \], $ \dots $ , \[ $ s,x_n $ \]. Note that if $ x_i
Input Format
The first line contains an integer $ t $ ( $ 1\le t\le 10^4 $ ) — the number of test cases.
The first line of each test case contains an integer $ n $ ( $ 1 \le n \le 2\cdot 10^5 $ ) — the number of points.
The second line contains $ n $ integers $ x_1,x_2 \dots x_n $ ( $ 1 \le x_i \le 10^9 $ ) — the coordinates of the points.
It is guaranteed that the sum of the values of $ n $ over all test cases does not exceed $ 2\cdot 10^5 $ .
Output Format
For each test case, output $ n $ integers, where the $ i $ -th integer is equal to the sum of the powers of all points for $ s=x_i $ .
Explanation/Hint
In the first test case we first choose $ s=x_1=1 $ , then the following segments are formed: $ [1,1] $ , $ [1,4] $ , $ [1,3] $ .
The powers of the points will be as follows: $ f_1=3, f_2=2, f_3=2, f_4=1, f_5=0 \dots $ The sum of powers of the points: $ 3+2+2+1+0+\dots+0=8 $ .
After that we choose $ s=x_2=4 $ . Then there will be such segments: $ [1,4] $ , $ [4,4] $ , $ [3,4] $ , and powers of the points are $ f_1=1, f_2=1, f_3=2, f_4=3 $ .
At the end we take $ s=x_3=3 $ and the segments look like this: $ [1,3] $ , $ [3,4] $ , $ [3,3] $ , the powers of the points are $ f_1=1, f_2=1, f_3=3, f_4=1 $ .