【UVA】【11021】麻球繁衍
数序期望
刘汝佳老师的白书上的例题……参见白书
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 //UVA 11021 2 #include<cmath> 3 #include<cstdio> 4 #define rep(i,n) for(int i=0;i<n;++i) 5 #define F(i,j,n) for(int i=j;i<=n;++i) 6 const int N=1010; 7 int n,m,k; 8 double p[N],f[N]; 9 int main(){ 10 int t; 11 scanf("%d",&t); 12 F(cs,1,t){ 13 scanf("%d%d%d",&n,&k,&m); 14 rep(i,n) scanf("%lf",&p[i]); 15 f[0]=0; f[1]=p[0]; 16 F(i,2,m){ 17 f[i]=0; 18 rep(j,n) f[i]+=p[j]*pow(f[i-1],j); 19 } 20 printf("Case #%d: %.7lf\n",cs,pow(f[m],k)); 21 } 22 return 0; 23 }