链接:http://acm.hdu.edu.cn/showproblem.php?pid=5645
#include <bits/stdc++.h>
#define c_false cin.tie(0);ios::sync_with_stdio(false); cout.tie(0)
using namespace std;
int a[305];
int main()
{
c_false;
int t, n;
cin >> t;
while(t--)
{
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
double ans = 0.0;
if(n == 1)
{
cout.setf(ios::fixed);
cout << setprecision(6) << ans << endl;
continue;
}
sort(a, a + n);
double ret = 1.0 / n;
for(int i = 1; i < n; i++)
{
int pos;
for(int j = i; j >= 0; j--)
{
if(a[j] > a[j - 1])
{
pos = j;
break;
}
}
double temp = pos * 1.0 / (n - 1);
ans += ret * temp;
}
cout.setf(ios::fixed);
cout << setprecision(6) << ans << endl;
}
return 0;
}