标签:
Description
Input
Output
1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> 5 6 using namespace std; 7 8 double f[1005][1005]; 9 10 int main() 11 { 12 int n,s; 13 while(~scanf("%d%d",&n,&s)) 14 { 15 memset(f,0,sizeof(f)); 16 for(int i=n;i>=0;i--) 17 for(int j=s;j>=0;j--) 18 { 19 if(n==i&&j==s)continue; 20 f[i][j]=(double)(f[i+1][j]*(n-i)*j+f[i][j+1]*i*(s-j)+f[i+1][j+1]*(n-i)*(s-j)+n*s)/(n*s-i*j); 21 } 22 printf("%.4f\n",f[0][0]); 23 } 24 return 0; 25 }
标签:
原文地址:http://www.cnblogs.com/tuigou/p/4639458.html