【POJ3071】Football
来源:互联网 发布:java支付宝开发流程 编辑:程序博客网 时间:2024/04/29 03:58
题目链接:传送门
题解:
求概率正着递推即可
令
我们把比赛流程图画出来,发现它其实是一个二叉树的结构
它的对手应该是它父节点另一棵子树的叶节点的任意一个
我们把所有选手从零开始编号,发现这个东西其实在二进制下是很好判断的(很难具体说出来,自己看代码模拟就好)
貌似我被精度卡了好久hhh
说出来你们可能不信,我把
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N=130;double f[N][N],p[N][N];int n,tot,ans;int main(){ while(~scanf("%d",&n)&&n!=-1) { tot=(1<<n); for(int i=0;i<tot;i++) for(int j=0;j<tot;j++) scanf("%lf",&p[i][j]); for(int i=0;i<tot;i++) f[0][i]=1; for(int i=1;i<=n;i++) for(int j=0;j<tot;j++) { int h=(j/(1<<(i-1)))^1; int l=h*(1<<(i-1)); int r=l+(1<<(i-1))-1; f[i][j]=0; for(int k=l;k<=r;k++) f[i][j]+=f[i-1][k]*p[j][k]*f[i-1][j]; } ans=0; for(int i=1;i<tot;i++) if(f[n][i]>f[n][ans]) ans=i; printf("%d\n",ans+1); } return 0;}
阅读全文
0 0
- POJ3071 Football
- POJ3071--Football
- poj3071 Football
- poj3071 Football
- POJ3071---Football
- 【POJ3071】【Football】
- poj3071 Football
- 【POJ3071】Football
- poj3071——Football
- POJ3071:Football(概率DP)
- Football(poj3071,概率DP)
- 树型dp poj3071 Football
- POJ3071 Football 【概率dp】
- poj3071--Football(概率计算)
- [POJ3071]Football(概率dp)
- 【POJ3071】Football(概率dp)
- POJ3071-Football(概率DP+滚动数组)
- poj3071
- 第二周
- poj 2138 Travel Games 搜索+自动机水题
- 多线程---yield
- Spark学习(一)基础数据预处理
- CSS3更多属性 浏览器私有前缀
- 【POJ3071】Football
- Is Derek lying?
- 1703-MySQL-DBCP连接池配置)
- mac系统使用chrome浏览器快捷键总结
- C语言模拟实现atoi函数
- 多线程----sleep
- hdu1075 字典树
- Spring Boot 配置大全
- g++: cannot specify -o with -c or -S with multiple files 和nm: test.o: File format not reco 的原因和解决方案