POJ 2151 Check the difficulty of problems 概率DP
2013-04-14 20:56
381 查看
poj g++坑人大法,c++ 就过了
#include<cstdio> #include<cstring> const int LMT=1012; double dp[LMT][LMT],_no[LMT][LMT]; void init(void) { memset(dp,0,sizeof(dp)); } int main(void) { int s,n,i,j; while(~scanf("%d%d",&n,&s)) { init(); for(i=0;i<=n;i++) for(j=0;j<=s;j++) _no[i][j]=i*j*1.0/(n*s); for(i=n;i>=0;i--) for(j=s;j>=0;j--) { if(i==n&&j==s)continue; if(i<n) dp[i][j]+=dp[i+1][j]*(n-i)*j/(n*s); if(i<n&&j<s) dp[i][j]+=dp[i+1][j+1]*(n-i)*(s-j)/(n*s); if(j<s) dp[i][j]+=dp[i][j+1]*i*(s-j)/(n*s); dp[i][j]=(dp[i][j]+1)/(1-_no[i][j]); } printf("%.4lf\n",dp[0][0]); } return 0; }
相关文章推荐
- poj 2151 Check the difficulty of problems(概率dp)
- POJ 2151 Check the difficulty of problems(dp,求概率)
- POJ 2151 Check the difficulty of problems(概率DP)
- POJ - 2151-Check the difficulty of problems-概率dp
- poj 2151 Check the difficulty of problems(概率dp)
- poj 2151 Check the difficulty of problems(概率DP)
- POJ 2151 Check the difficulty of problems (概率dp)
- POJ 2151 Check the difficulty of problems (概率DP)
- poj 2151 Check the difficulty of problems(概率dp)
- POJ-2151 Check the difficulty of problems 概率DP
- poj 2151 Check the difficulty of problems 概率dp
- POJ 2151 Check the difficulty of problems(概率dp啊)
- POJ 2151 Check the difficulty of problems (概率DP)
- POJ 2151 Check the difficulty of problems(概率dp)
- Poj 2151 Check the difficulty of problems (概率DP)
- POJ_2151_Check the difficulty of problems_概率DP
- POJ 2151 Check the difficulty of problems(概率dp)
- poj 2151 Check the difficulty of problems 概率dp
- Check the difficulty of problems - POJ 2151 概率dp
- [ACM] POJ 2151 Check the difficulty of problems (概率+DP)