概率dp的典型题。用dp[j][i]表示第j个队第i场赢的概率。那么这场要赢就必须前一场赢了而且这一场战胜了可能的对手。这些都好想,关键是怎么找出当前要算的队伍的所有可能的竞争对手?这个用异或来算,从队伍编号的二进制表示中可以看出规律来(从二进制和相关运算里找规律也是一个重要的思考角度)。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<cctype>
#include<sstream>
using namespace std;
#define pii pair<int,int>
#define LL long long int
const int eps=1e-;
const int INF=;
const int maxn=+;
int n;
double maps[][],dp[][];
int main()
{
//freopen("in8.txt","r",stdin);
while(scanf("%d",&n)==&&(n!=-))
{
int sum=<<n;//total athletes
for(int i=; i<sum; i++)
{
for(int j=; j<sum; j++)
{
scanf("%lf",&maps[i][j]);
}
dp[i][]=;
}
for(int i=; i<n; i++)
{
for(int j=; j<sum; j++)
{
double tol=;
for(int k=(<<i); k<(<<(i+)); k++)
{
tol+=dp[j^k][i]*maps[j][j^k];
}
dp[j][i+]=dp[j][i]*tol;
}
}
double ans=-;int t;
for(int i=; i<sum; i++)
{
if(dp[i][n]>ans) ans=dp[i][n],t=i;
}
printf("%d\n",t+);
}
//fclose(stdin);
//fclose(stdout);
return ;
}

POJ 3071 Football (概率DP)的更多相关文章

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

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

  2. POJ 3071 Football(概率DP)

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

  3. poj 3071 Football(概率dp)

    id=3071">http://poj.org/problem? id=3071 大致题意:有2^n个足球队分成n组打比赛.给出一个矩阵a[][],a[i][j]表示i队赢得j队的概率 ...

  4. POJ 3071 Football

    很久以前就见过的...最基本的概率DP...除法配合位运算可以很容易的判断下一场要和谁比.    from——Dinic算法                         Football Time ...

  5. POJ3071:Football(概率DP)

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

  6. POJ 3156 - Interconnect (概率DP+hash)

    题意:给一个图,有些点之间已经连边,现在给每对点之间加边的概率是相同的,问使得整个图连通,加边条数的期望是多少. 此题可以用概率DP+并查集+hash来做. 用dp(i,j,k...)表示当前的每个联 ...

  7. poj 1322 Chocolate (概率dp)

    ///有c种不同颜色的巧克力.一个个的取.当发现有同样的颜色的就吃掉.去了n个后.到最后还剩m个的概率 ///dp[i][j]表示取了i个还剩j个的概率 ///当m+n为奇时,概率为0 # inclu ...

  8. [poj3071]football概率dp

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

  9. POJ 3071 Football:概率dp

    题目链接:http://poj.org/problem?id=3071 题意: 给定n,有2^n支队伍参加足球赛. 给你所有的p[i][j],表示队伍i打败队伍j的概率. 淘汰赛制.第一轮(1,2)两 ...

随机推荐

  1. LeetCode-day03

    28. Best Time to Buy and Sell Stock 买卖股票的最好时间 29. Best Time to Buy and Sell Stock II 买卖股票2(多次买入,一次卖出 ...

  2. Python之匿名函数(Day18)

    匿名函数 为了解决那些功能很简单的的需求而设计的一句话函数 #这段代码 def calc(n): return n**n print(calc(10)) #换成匿名函数 calc = lambda n ...

  3. Android:日常学习笔记(9)———探究广播机制

    Android:日常学习笔记(9)———探究广播机制 引入广播机制 Andorid广播机制 广播是任何应用均可接收的消息.系统将针对系统事件(例如:系统启动或设备开始充电时)传递各种广播.通过将 In ...

  4. iOS 认识runtime 中的三个指针 isa , IMP , SEL

    runtime中函数调用经常被提及的三个概念 isa,IMP,SEL 一  isa:是类指针,之所以说isa是指针是因为Class其实是一个指向objc_class结构体的指针,而isa 是它唯一的私 ...

  5. iOS CMTimeMake 和 CMTimeMakeWithSeconds 学习

    CMTime是专门用于标识电影时间的结构体,通常用如下两个函数来创建CMTime (1)CMTimeMake CMTime CMTimeMake ( int64_t value, //表示 当前视频播 ...

  6. 所有文本的 attributes 枚举,NSAttributedString

    // Predefined character attributes for text. If the key is not in the dictionary, then use the defau ...

  7. OC源文件扩展名

    常见的文件扩展名 扩展名 含义 扩展名 含义 .c C语言源文件 .mm Objective-C++源文件 .cc..cpp C++源文件 .pl Perl源文件 .h 头文件 .o Object(编 ...

  8. 一个不成熟的编程员,写写 js 的面向对象

    其实感觉本人 js 并未入门,甚至说也是个不合格的编程员,什么面向对象都不会,一直都往 Object 里面填方法,假装很对象的样子. 但学习嘛,这道坎还是得多试几下的,说不定就跨过去了呢. 个人喜欢用 ...

  9. 解决:Requested 'libdrm_radeon >= 2.4.56' but version of libdrm_radeon is 2.4.52

    checking for NOUVEAU... yes checking for RADEON... no configure: error: Package requirements (libdrm ...

  10. 去duplicate的方法

    1.什么是duplicate,为什么要去除. 什么是duplicate:这是在建库的过程后,对已连有接头的DNA片段进行扩增,然后去接flowcell.之所以在建库后扩增,这是由于接flowcell的 ...