poj-3071-Football-概率模拟
来源:互联网 发布:java web excel预览 编辑:程序博客网 时间:2024/06/03 12:38
直接模拟比赛过程。
ans[i][j]:第i次比赛,第j个人获胜的概率。
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;double maps[1001][1001];double ans[1001][1001];int main(){ int n,m,i,j,k; while(~scanf("%d",&m)&&(m!=-1)) { n=1<<m; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { scanf("%lf",&maps[i][j]); } } memset(ans,0,sizeof(ans)); for(j=1;j<=n;j++)ans[0][j]=1.0; int leap=0; int ts; for(i=1;i<=m;i++) { leap=1; ts=1<<(i-1); for(j=1;j<=n;j++) { int st,ed; st=j-(j-1)%ts+leap*ts; ed=j-(j-1)%ts+leap*ts+ts-1; for(k=st;k<=ed;k++) { ans[i][j]+=ans[i-1][j]*ans[i-1][k]*maps[j][k]; } if(j%ts==0)leap=-leap; } } double maxx=0; int st=1; for(i=1;i<=n;i++) { if(ans[m][i]>maxx) { maxx=ans[m][i]; st=i; } } cout<<st<<endl; }}
0 0
- poj-3071-Football-概率模拟
- POJ 3071 Football(概率问题)
- poj 3071 Football 概率dp
- POJ 3071 Football 概率DP
- poj 3071 football 概率dp
- poj 3071 Football(概率dp)
- POJ 3071 Football (概率DP)
- poj 3071 Football 概率dp
- Football - POJ 3071 概率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]
- RTC 3.0.1.5 Backup
- Android中 dip 和 px 的关系
- PHP 数组处理(一)
- C++ builder XE2 版本编译独立运行程序
- Shell脚本调试技术
- poj-3071-Football-概率模拟
- nginx日志分析
- [leet code] Sort Colors
- 黑马程序员_IO操作规律总结
- java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index
- gcc 中-I、 -L 与-l选项的作用
- Android 数据存储
- 图解Android - Zygote, System Server 启动分析
- LeetCode - Populating Next Right Pointers in Each Node