POJ 3071 Football 概率DP
2013-04-14 20:49
447 查看
做法:一开始粗心了,算某个人晋升的概率时要考虑他自己到当前这种等级的概率和他的对手到这种等级的概率,还有他自己打败他的对手的概率,2了第一个概率没有乘。
#include<cstdio> #include<cstring> const int LMT=7; double dp[LMT+3][1<<LMT],mat[1<<LMT][1<<LMT]; int n; void init(void) { int i; memset(dp,0,sizeof(dp)); for(i=0;i<(1<<n);i++)dp [i]=1.0; } int main(void) { int i,j,t,lim,pos,d; double ans; while(~scanf("%d",&n)&&~n) { init(); ans=-1;pos=-1; lim=1<<n; for(i=0;i<lim;i++) for(j=0;j<lim;j++) scanf("%lf",&mat[i][j]); for(i=n-1;i>=0;i--) for(j=0;j<lim;j++) { d=j/(1<<(n-i-1)); if(!(d&1)) { for(t=(d+1)*(1<<(n-i-1));t<(d+2)*(1<<(n-i-1));t++) dp[i][j]+=dp[i+1][j]*dp[i+1][t]*mat[j][t]; } else { for(t=(d-1)*(1<<(n-i-1));t<d*(1<<(n-i-1));t++) dp[i][j]+=dp[i+1][j]*dp[i+1][t]*mat[j][t]; } } for(i=0;i<lim;i++) if(ans<dp[0][i]) { ans=dp[0][i]; pos=i+1; } printf("%d\n",pos); } return 0; }
相关文章推荐
- POJ 3071 Football(概率dp)
- poj 3071 Football (概率DP水题)
- POJ 3071 Football (概率DP)
- POJ 3071 Football (概率DP)
- POJ 3071 Football(概率DP)
- POJ 3071 Football 概率DP 二进制优化
- poj-3071 Football 【概率dp,位运算】
- POJ-3071 Football (概率dp)
- POJ 3071 Football 概率DP
- POJ 3071 Football (概率DP)
- poj 3071 Football (概率DP水题)
- POJ 3071 Football 【概率DP】
- [ACM] POJ 3071 Football (概率DP)
- POJ 3071 - Football(概率DP 求概率)
- POJ 3071 Football(概率DP)
- POJ 3071 Football 概率DP入门
- Poj 3071 Football (比赛对阵 概率DP)
- poj 3071 Football(概率dp)
- POJ 3071 Football(概率DP)
- poj 3071 Football(概率dp)