http://poj.org/problem?id=3071

题意:有2^n个队伍,给出每两个队伍之间的胜率,进行每轮淘汰数为队伍数/2的淘汰赛(每次比赛都是相邻两个队伍进行),问哪只队伍成为冠军概率最大。
很基础。
代码
 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
const int maxn=;
const double eps=1e-;
const int modn=;
int n;
double a[<<][<<]={};
double f[<<][]={};
int main(){
while(scanf("%d",&n)){
if(n==-)return ;
memset(f,,sizeof(f));memset(a,,sizeof(a));
int z=<<n;
for(int i=;i<=z;i++){
for(int j=;j<=z;j++){
scanf("%lf",&a[i][j]);
}
}
for(int i=;i<=z;i++){f[i][]=;}
for(int i=;i<=n;i++){
for(int j=;j<=z;j++){
int t=(j-)/(<<i);
t=t*(<<i); t+=(<<(i-))+;
if(t<=j)t=t-(<<(i-));
int en=t+(<<(i-))-;
for(int w=t;w<=en;w++){
f[j][i]+=a[j][w]*f[w][i-]*f[j][i-];
}
}
}double ans=0.0;int id=;
for(int i=;i<=z;i++){
if(f[i][n]>ans){
ans=f[i][n];
id=i;
}
}printf("%d\n",id);
}
return ;
}

POJ3071 Football 概率DP 简单的更多相关文章

  1. POJ3071:Football(概率DP)

    Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, …, 2 ...

  2. [poj3071]football概率dp

    题意:n支队伍两两进行比赛,求最有可能获得冠军的队伍. 解题关键:概率dp,转移方程:$dp[i][j] +  = dp[i][j]*dp[i][k]*p[j][k]$表示第$i$回合$j$获胜的概率 ...

  3. Football 概率DP poj3071

                                                                                                 Footbal ...

  4. poj 3071 Football (概率DP水题)

    G - Football Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit ...

  5. poj3071之概率DP

    Football Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2667   Accepted: 1361 Descript ...

  6. POJ 3071 Football(概率DP)

    题目链接 不1Y都对不住看过那么多年的球.dp[i][j]表示i队进入第j轮的概率,此题用0-1<<n表示非常方便. #include <cstdio> #include &l ...

  7. HDU 3853 期望概率DP

    期望概率DP简单题 从[1,1]点走到[r,c]点,每走一步的代价为2 给出每一个点走相邻位置的概率,共3中方向,不动: [x,y]->[x][y]=p[x][y][0] ,  右移:[x][y ...

  8. 2018.09.01 poj3071Football(概率dp+二进制找规律)

    传送门 概率dp简单题. 设f[i][j]表示前i轮j获胜的概率. 如果j,k能够刚好在第i轮相遇,找规律可以发现j,k满足: (j−1)>>(i−1)" role=" ...

  9. poj3071 Football(概率dp)

    poj3071 Football 题意:有2^n支球队比赛,每次和相邻的球队踢,两两淘汰,给定任意两支球队相互踢赢的概率,求最后哪只球队最可能夺冠. 我们可以十分显然(大雾)地列出转移方程(设$f[ ...

随机推荐

  1. python模块之imghdr检测图片类型

    1. imghdr是什么 imghdr是一个用来检测图片类型的模块,传递给它的可以是一个文件对象,也可以是一个字节流. 能够支持的图片格式: 2. 如何使用 提供了一个api叫做imghdr.what ...

  2. python作业Select版本FTP(第十周)

    SELECT版FTP: 使用SELECT或SELECTORS模块实现并发简单版FTP 允许多用户并发上传下载文件 思路解析: 1. 使用IO多路复用的知识使用SELECTORS封装好的SELECTOR ...

  3. 打表找规律C - Insertion Sort Gym - 101955C

    题目链接:https://cn.vjudge.net/contest/273377#problem/C 给你 n,m,k. 这个题的意思是给你n个数,在对前m项的基础上排序的情况下,问你满足递增子序列 ...

  4. Android中注册获取验证码倒计时按钮

    public class CountDownTimerUtils extends CountDownTimer { private TextView mTextView; /** * @param t ...

  5. oracle查看表中数据的大小

    通过从视图 user_segments的字段 bytes中找到 select SUM(bytes)/1024/1024 from user_segments where segment_name='E ...

  6. arch优化开机

    查看开机时间 systemd-analyze 具体开机时间 systemd-analyze blame 你可以systemctl --all | grep not-found 查看有哪些服务挂掉了.然 ...

  7. 64_p5

    php-nette-bootstrap-2.4.3-1.fc26.noarch.rpm 20-Feb-2017 07:19 16290 php-nette-caching-2.5.3-1.fc26.n ...

  8. Shp上传至Oracle Spatial

    1.下载shp2sdo,将shp文件拷贝至shp2sdo相同路径下,打开windows命令窗口,执行: shp2sdo shp文件名 表名 -i id -s 4326 -d 例如:shp2sdo ci ...

  9. nginx报502修复日志

    参考:https://www.baidu.com/link?url=PGd7mgvalnQp0MOVZTyDJIvr6_eJn1hmPlmsLpdj2vH6w3FzMt3pZEd_MKpoiqX1OF ...

  10. SuSE Linux Supervisor的安装与使用案例

      建议使用 root 管理员账户操作 1.安装工具 1.apache 2..Net Core(dotnet-sdk-2.0) 3.Supervisor(进程管理工具,目的是服务器一开机就启动服务器 ...