Kevin has recently learned the definition of variance. For an array $$$a$$$ of length $$$n$$$, the variance of $$$a$$$ is defined as follows:
Now, Kevin gives you an array $$$a$$$ consisting of $$$n$$$ integers, as well as an integer $$$k$$$. You can perform the following operation on $$$a$$$:
For each $$$1\le p\le m$$$, you have to find the minimum possible variance of $$$a$$$ after exactly $$$p$$$ operations are performed, independently for each $$$p$$$.
For simplicity, you only need to output the answers multiplied by $$$n^2$$$. It can be proven that the results are always integers.
Each test contains multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1\le t\le 100$$$) — the number of test cases. The description of test cases follows.
The first line of each test case contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$1\le n,m\le 5000$$$, $$$\color{red}{n\cdot m\le 2\cdot 10^4}$$$, $$$1\le k\le 10^5$$$) — the length of the array $$$a$$$, the maximum number of operations, and the number you add to $$$a_i$$$ each time, respectively.
The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots, a_n$$$ ($$$1\le a_i\le 10^5$$$) — the elements of the array $$$a$$$.
It is guaranteed that the sum of $$$n\cdot m$$$ over all tests does not exceed $$$2\cdot 10^4$$$.
For each test case, output $$$m$$$ integers in a single line, the $$$p$$$-th integer denoting the minimum possible variance of $$$a$$$ when exactly $$$p$$$ operations are performed, multiplied by $$$n^2$$$.
93 2 11 2 23 2 21 2 210 2 110 1 1 1 1 10 1 1 1 16 8 21 1 4 5 1 38 8 720 43 24 2 4 3 20 438 8 320 43 24 2 4 3 20 4310 12 15 3 3 5 4 1 8 1 1 113 10 1000001 2 3 4 5 6 7 8 9 10 11 5 410 5 100002308 9982 4435 3310 100000 9 7 8100 1919 100000
0 0 2 2 1161 1024 53 21 21 5 5 5 5 5 10608 6912 4448 3104 1991 1312 535 304 13248 11184 9375 7815 6447 5319 4383 3687 385 316 269 224 181 156 124 101 80 56 41 29 1486 1486 1486 1486 1486 1486 1486 1486 1486 1486 134618047140 119919447140 107020847140 93922247140 82623647140
In the first test case:
In the second test case, some possible optimal choices are:
In the third test case, some possible optimal choices are:
In the eighth test case, the optimal choice for all $$$p$$$ is to perform the operation on the whole array $$$p$$$ times.
Name |
---|