cf 678E
来源:互联网 发布:循环更新数据库 编辑:程序博客网 时间:2024/06/04 19:02
题意:
一共有n个人打擂台,第一个人是主角,他能任意选择那两个人相互比较,赢得成为擂主,继续和其他人比较,
问,主角想赢的概率最大多大。
题解:
dp[i][j]代表存活人集合为i的情况下j为擂主,主角获胜的概率,
so : dp[stat][i]=max(dp[stat][i],a[i][j]*dp[stat^(1<<j)][i]+a[j][i]*dp[stat^(1<<i)][j]);
#include<bits/stdc++.h>#define ll long longusing namespace std;const int maxn=20;double a[maxn][maxn];double dp[1<<20][maxn];//存活人集合为i的情况下j为擂主主角获胜概率int main(){ int n; scanf("%d",&n); for(int i=0;i<n;++i) for(int j=0;j<n;++j) scanf("%lf",&a[i][j]); dp[1][0]=1; for(int stat=3;stat<(1<<n);stat+=2){ for(int i=0;i<n;++i)if(stat&(1<<i)){ for(int j=0;j<n;++j)if(j!=i&&(stat&(1<<j))){ dp[stat][i]=max(dp[stat][i],a[i][j]*dp[stat^(1<<j)][i]+a[j][i]*dp[stat^(1<<i)][j]); } } } double ans=0; for(int i=0;i<n;++i) ans=max(ans,dp[(1<<n)-1][i]); printf("%.10lf",ans); return 0;}
阅读全文
0 0
- cf 678 E
- cf 678E
- cf-e
- cf 678E Another Sith Tournament
- e-Government CF 163E
- e-Government CF 163E
- cf 163e e-Government
- CF 208E
- CF #148 DIV2 E
- CF 145E
- CF 121E
- CF 338E Optimize!
- Holes CF 13E
- cf-282e
- CF 16E Fish
- cf#ff(div2)E
- CF 260div2 E
- cf 459E DP
- JVM——Java类加载机制总结
- js、css、jsp文件压缩
- 在网络通讯中,实现把一个int类型的值从服务器传输到另外一个电脑上
- ubuntu依赖包问题 版本问题
- SAS中取整函数(round、ceil、floor、int)用法详解
- cf 678E
- 75. Sort Colors
- java web 项目中可能出现乱码的原因
- 利用Java输出九九乘法表(从四个方向排列)
- C语言的const和指针
- D_D系统构建-篇外话
- Codeforces862 E. Mahmoud and Ehab and the function
- translate和ktranslate用法详解
- Hbuilder增加vuejs、angularjs代码提示