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. laravel 重定向路由带参数

    转载: http://www.cnblogs.com/foreversun/p/5642176.html 举例: 路由: //任务列表页 $router->get('/taskDetail/{i ...

  2. 谈一谈我所了解的https

    一. http协议 首先我并不会很深入的去探讨这个东西,即使我曾经花了很长的时间去研究这个东西.主要是我考虑到1. 自己没有系统的去学习这一块的知识,讲解的会比较的肤浅.2. 就算是懂这个东西也不一定 ...

  3. Redis数据类型之字符串(string)

    1. string类型简介 string类型是二进制安全的,能够存储任意类型的字符串. string类型是最常用到的数据类型,一种常用的用法就是将对象格式化为JSON字符串然后放到redis中,取出来 ...

  4. JS日历控件特效代码layDate

    https://www.js-css.cn/a/jscode/date/2015/0405/1461.html

  5. git push multiple repo

    git remote add xxx https://git.github.com

  6. apache2启动失败(Failed to start The Apache HTTP Server.)解决方案

    不知道如何启动apache2就启动不来了. 如下图所示: 即使卸载了重新装也是如此 经过测试卸载并清除软件包的配置即可解决 sudo apt-get purge apache2  sudo apt-g ...

  7. C# 加密解密以及sha256不可逆加密案例

    class Program { static void Main(string[] args) { string aa = "身份证"; string bb = "key ...

  8. mac 卸载 node并重新安装

    系统升级到 Sierra 之后,npm 经常出问题,最终把 node 卸载了,安装了新版本.mac 卸载 node 比较麻烦,stackoverflow 上面找到一个方法还不错,特地记录下来,代码如下 ...

  9. Web服务器处理动态程序三种方式及Apache配置

    模块.CGI.FastCGI三种方式介绍 以PHP脚本为例: 模块方式是指Web服务器通过libphp5.so模块调用PHP服务,模块将相关函数嵌入Web服务请求处理流程,不需要额外解释器进程.注意, ...

  10. PostGIS 操作geometry方法

    WKT定义几何对象格式: POINT(0 0) ——点 LINESTRING(0 0,1 1,1 2) ——线 POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2 ...