【51Nod 1756】【算法马拉松 23】谷歌的恐龙
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1765
设答案为\(X\)。
则$$X=\frac{m}{n}\times\frac{\sum a_i}{m}+\frac{n-m}{n}\left(\frac{\frac{(n-1)n}{2}-\sum a_i}{n-m}+X\right)$$
\[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\n", 1.0 * n * (n - 1) / 2 / m);
return 0;
}
NOI 2017 Bless All