先假设一开始是一只麻球 d[i]是i天内死亡的概率
d[i] = P0 * d[i-1]^0 + P1 * d[i-1] + P2 * d[i-2]^2 + ... + Pn-1 * d[i-1] ^ (n-1)
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#define SF scanf
#define PF printf
using namespace std;
typedef long long LL;
const int MAXN = 1000;
int n, k, m, kase;
double P[MAXN+10], d[MAXN+10];
int main()
{
int T; SF("%d", &T); while(T--) {
SF("%d%d%d", &n, &k, &m);
for(int i = 0; i < n; i++) SF("%lf", &P[i]);
d[1] = P[0];
for(int i = 2; i <= m; i++) {
d[i] = 0;
for(int j = 0; j < n; j++) d[i] += P[j] * pow(d[i-1], j);
}
PF("Case #%d: %.7lf\n", ++kase, pow(d[m], k));
}
}