题目描述
Given an array of integers $Y=[y_1,y_2,\ldots,y_n]$, we have $n$ line segments, such that, the endpoints of $i^{\mbox{th}}$ segment are $(i,0)$ and $(i,y_i)$. Imagine that from the top of each segment a horizontal ray is shot to the left, and this ray stops when it touches another segment or it hits the y-axis. We construct an array of $n$ integers, $[v_1,v_2,\ldots,v_n]$, where $v_i$ is equal to length of ray shot from the top of segment $\boldsymbol{i}$. We define $V(y_1,y_2,...,y_n)=v_1+v_2+…+v_n$.
For example, if we have $Y=[3,2,5,3,3,4,1,2]$, then $v_1,v_2,...,v_8=[1,1,3,1,1,3,1,2]$, as shown in the picture below:
For each permutation $\boldsymbol{p}$ of $[1,2,\ldots,n]$, we can calculate $V(y_{p_1},y_{p_2},\ldots,y_{p_n})$. If we choose a uniformly random permutation $\boldsymbol{p}$ of $[1,2,\ldots,n]$, what is the expected value of $V(y_{p_1},y_{p_2},\ldots,y_{p_n})$?
Input Format
The first line contains a single integer T (1 <=T<= 100). T test cases follow.
The first line of each test-case is a single integer N (1 <= n <= 50), and the next line contains positive integer numbers $y_1,y_2\ldots,y_n$ separated by a single space ($0<y_i<=1000$).
Output Format
For each test-case output expected value of $V(y_{p_1},y_{p_2},\ldots,y_{p_n})$, rounded to two digits after the decimal point.
Sample Input
6
3
1 2 3
3
3 3 3
3
2 2 3
4
10 2 4 4
5
10 10 10 5 10
6
1 2 3 4 5 6
Sample Output
4.33
3.00
4.00
6.00
5.80
11.15
Explanation
Case 1: We have $V(1,2,3)=1+2+3=6,V(1,3,2)=1+2+1=4,V(2,1,3)=1+1+3=5$,
$V(2,3,1)=1+2+1=4,V(3,1,2)=1+1+2=4,V(3,2,1)=1+1+1=3$.
Average of these values is 4.33.
Case 2: No matter what the permutation is, $V(y_{p_1},y_{p_2},y_{p_3})=1+1+1=3$, so the answer is 3.00.
Case 3: $V(y_1,y_2,y_3)=V(y_2,y_1,y_3)=5$,
$V(y_1,y_3,y_2)=V(y_2,y_3,y_1)=4$,
$V(y_3,y_1,y_2)=V(y_3,y_2,y_1)=3$,
and average of these values is 4.00.
输入格式
见题面
输出格式
见题面