题目传送门:https://vjudge.net/contest/361424#problem/G
题意:给出一个n面色子,现在扔色子,知道所有面都出现一次,问掷色子次数的期望值。
题目解析:假设现在已经掷出了k个不同的面,再掷下一次的过程是一次伯努利实验,即X(首次掷出新面需要的投掷次数)服从参数p( 掷出新面的概率是(n-k) / n )的几何分布,因此E(X)=1/p。
k从0到n,把对应的期望累加起来就好了。

#include <bits/stdc++.h>
#define eps 1e-10
using namespace std;
const int N = 1e5+7;
double rec[N];
int main()
{
   
	int t,cnt=0;
	scanf("%d", &t);
	while(t--) {
   
		int n,p;
		scanf("%d", &n);
		for(int i=0; i<n; i++) {
   
			rec[i]= n*1.0/(n-i) + rec[i-1];
		}
		printf("Case %d: %.6f\n",++cnt,rec[n-1]+eps);
	}
	return 0;
}