标签:
大概题意:有n个子系统,s种bug,每次找出一个bug,这个bug属于第 i 个子系统的概率为1/n,是第 j 种bug的概率是1/s,问在每个子系统中至少找出一个bug,且每种bug都找到过,总共需要找到bug的总数的期望值(我擦我这破烂语文水平……还不如不翻译)
题解:http://www.cnblogs.com/zhj5chengfeng/archive/2013/03/02/2939597.html
1 //POJ 2096 2 #include<cstdio> 3 #include<cstring> 4 #define D(i,j,n) for(int i=j;i>=n;--i) 5 #define pb push_back 6 using namespace std; 7 8 double f[1010][1010]; 9 int main(){ 10 int n,s; 11 while(scanf("%d%d",&n,&s)!=EOF){ 12 memset(f,0,sizeof (f)); 13 D(i,n,0) 14 D(j,s,0){ 15 if (i==n && j==s) continue; 16 double p1=(double(s-j)*i)/n/s, 17 p2=(double(n-i)*j)/n/s, 18 p3=(double(n-i)*(s-j))/n/s, 19 p0=1.0-(double(i*j))/n/s; 20 f[i][j]=p1*f[i][j+1]+p2*f[i+1][j]+p3*f[i+1][j+1]+1; 21 f[i][j]/=p0; 22 } 23 printf("%.4f\n",f[0][0]); 24 } 25 return 0; 26 }
标签:
原文地址:http://www.cnblogs.com/Tunix/p/4300399.html