poj 3071 Football
来源:互联网 发布:flux软件 编辑:程序博客网 时间:2024/04/28 23:13
题目:poj 3071 Football
tag:概率dp
思路:
Round1 :
0 play with 1
2 play with 3
4 play with 5
...
Round 2:
0 can play with 2 or 3 vice versa
1 can play with 2 or 3 vice versa
4 can play with 6 or 7 vice versa
5 can play with 6 or 7 vice versa
...
Round i
player j can play with k
only (j>>(i-1)) == ( (k>>(i-1))^1)
#include <cstring>#include <algorithm>#include <cmath>#include <iostream>#include <cstdio>using namespace std;#define maxn ((1<<7)+1)double dp[8][maxn];double p[maxn][maxn];int main(){int n;while(scanf("%d",&n)!=EOF){if(n==-1)break;memset(dp,0,sizeof(dp));int m=(1<<n);for(int i=0;i<m;i++)dp[0][i]=1;for(int i=0;i<m;i++)for(int j=0;j<m;j++)scanf("%lf",&p[i][j]);for(int i=1;i<=n;i++)for(int j=0;j<m;j++){for(int k=0;k<m;k++){if((j>>(i-1)) == ((k>>(i-1))^1))dp[i][j]+=dp[i-1][k]*dp[i-1][j]*p[j][k];}}int ans=1;double mx=0;for(int i=0;i<m;i++){if(mx<dp[n][i]){mx=dp[n][i];ans=i;}}printf("%d\n",ans+1);}return 0;}
- poj 3071 Football
- poj 3071 football
- POJ 3071 Football
- POJ-3071-Football
- poj 3071 Football
- poj 3071 Football
- POJ 3071 Football
- POJ 3071 Football
- POJ 3071 Football
- POJ 3071 Football
- poj 3071 Football
- POJ 3071 Football
- poj 3071 Football DP
- POJ 3071:Football
- POJ 3071 Football
- POJ-3071-Football
- poj-3071-Football
- poj 3071 football
- Server problem trouble shooting
- 【美化§风景之雾漫城市之颠win7电脑主题】
- 继BAT之后 第四大巨头是谁
- 几个环境变量说明:ORACLE_SID、DB_NAME、INSTANCE_NAME、DB_DOMIAN、GLOBAL_NAMES
- 学生信息管理系统
- poj 3071 Football
- 最长公共子序列的动态规划求解
- Source Insight经典教程
- MySQL删除外键定义的方法
- uva 414
- uva 10499 - The Land of Justice
- 如何正确设置nginx中remote_addr和x_forwarded_for参数
- USCAO4.2 The Perfect Stall ,二分图最大匹配
- ArrayUtils用法