http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1765
设答案为(X)。
则$$X=frac{m}{n} imesfrac{sum a_i}{m}+frac{n-m}{n}left(frac{frac{(n-1)n}{2}-sum a_i}{n-m}+X
ight)$$
[X=frac{n(n-1)}{2m}
]
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n, m;
int main() {
scanf("%d%d", &n, &m);
printf("%.6lf
", 1.0 * n * (n - 1) / 2 / m);
return 0;
}