POJ3071 Football 【概率dp】
来源:互联网 发布:俄罗斯姑娘知乎 编辑:程序博客网 时间:2024/04/29 06:34
题目链接:http://poj.org/problem?id=3071
题意:
足球赛制是淘汰赛,每次是1和2打比赛,3和4……然后1和2的胜者和3和4的胜者打比赛,i打j的胜率是 Pij,问哪只队伍最有可能夺冠?(即获胜概率最高)。
题解:
简单的概率dp题,只需要判断一下j和k能否碰上即可。
代码:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;typedef long long LL;const int inf = 1 << 26;double f[205][205], a[205][205];int n;int main(){ while( scanf("%d", &n), n != -1){ memset(f, 0, sizeof(f)); for ( int i = 0; i < (1<<n); i ++ ) { for ( int j = 0; j < (1<<n); j ++ ) scanf("%lf", &a[i][j]); } for ( int i = 0; i < (1<<n); i ++ ) { f[0][i] = 1; } for ( int i = 1; i <= n; i ++) { for ( int j = 0; j < (1<<n); j ++ ) { for ( int k = 0; k< (1<<n); k ++ ) { if((k>>(i-1)^1) == (j >> (i-1))) { f[i][j] += a[j][k]*f[i-1][j]*f[i-1][k]; } } } } int ans = 0; for ( int i = 0; i < (1<<n); i ++ ) { if(f[n][i] > f[n][ans]) { ans = i; } } printf("%d\n", ans+1); } return 0;}
0 0
- POJ3071:Football(概率DP)
- Football(poj3071,概率DP)
- POJ3071 Football 【概率dp】
- [POJ3071]Football(概率dp)
- 【POJ3071】Football(概率dp)
- POJ3071-Football(概率DP+滚动数组)
- 树型dp poj3071 Football
- poj3071--Football(概率计算)
- poj3071(概率DP)
- poj3071(概率DP)
- poj3071之概率DP
- poj3071(概率DP)
- poj3071(概率dp)
- poj3071(概率dp)
- POJ3071 概率DP
- poj3071 概率dp
- poj3071 概率dp
- POJ3071 Football
- 友元函数小节(重读primer plus笔记细节问题)
- 父级内的元素垂直居中
- linux命令-文件及目录管理
- 3.3构架数组
- java中的IO流
- POJ3071 Football 【概率dp】
- action属性和input类型
- 第三章——多态
- java基础--3.面向对象-3.封装
- python读取pdf文档
- Http状态码大全(200、404、500等)
- 七、Mysql 常用命令
- mysql安装启动等常见问题总结
- 五、MYSQL 常用命令