【POJ 3071】 Football
【题目链接】
http://poj.org/problem?id=3071
【算法】
概率DP
f[i][j]表示第j支队伍进入第i轮的概率,转移比较显然
【代码】
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <stack>
#include <limits.h>
using namespace std; int i,j,k,n,pos;
double a[][],f[][]; int main()
{ while (scanf("%d",&n) != EOF && n != -)
{
memset(f,,sizeof(f));
for (i = ; i <= ( << n); i++)
{
for (j = ; j <= ( << n); j++)
{
scanf("%lf",&a[i][j]);
}
}
for (i = ; i <= ( << n); i++) f[][i] = 1.0;
for (i = ; i <= n + ; i++)
{
for (j = ; j <= ( << n); j++)
{
for (k = ; k <= ( << n); k++)
{
if ((((j - ) >> (i - )) ^ ) == ((k - ) >> (i - )))
f[i][j] += f[i-][k] * f[i-][j] * a[j][k];
}
}
}
pos = ;
for (i = ; i <= ( << n); i++)
{
if (f[n+][i] > f[n+][pos])
pos = i;
}
printf("%d\n",pos);
} return ;
}
【POJ 3071】 Football的更多相关文章
- 【POJ 3071】 Football(DP)
[POJ 3071] Football(DP) Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4350 Accepted ...
- bzoj 2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...
- 【链表】BZOJ 2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 382 Solved: 111[Submit][S ...
- BZOJ2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 284 Solved: 82[Submit][St ...
- BZOJ2293: 【POJ Challenge】吉他英雄
2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 80 Solved: 59[Submit][Stat ...
- BZOJ2287: 【POJ Challenge】消失之物
2287: [POJ Challenge]消失之物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 254 Solved: 140[Submit][S ...
- BZOJ2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 126 Solved: 90[Submit][Sta ...
- BZOJ2296: 【POJ Challenge】随机种子
2296: [POJ Challenge]随机种子 Time Limit: 1 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 114 Solv ...
- BZOJ2292: 【POJ Challenge 】永远挑战
2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 513 Solved: 201[Submit][ ...
随机推荐
- 使用TortoiseSVN碰到的几个问题(1)-导入,提交,更新
1)导入数据到版本库 第一种情况,使用Import导入命令的时候 不能选择包含哪些指定文件或目录, 导入的文件夹不能变成工作副本,(如果你在“工作副本”目录下执行导入命令是不起作用的.)必须通过签出操 ...
- dubbo之本地存根
本地存根 远程服务后,客户端通常只剩下接口,而实现全在服务器端,但提供方有些时候想在客户端也执行部分逻辑,比如:做 ThreadLocal 缓存,提前验证参数,调用失败后伪造容错数据等等,此时就需要在 ...
- OpenCv:椭圆上点的计算方程
椭圆 椭圆(Ellipse)是平面内到定点F1.F2的距离之和等于常数(大于|F1F2|)的动点P的轨迹,F1.F2称为椭圆的两个焦点.其数学表达式为: ...
- css3基础篇三
CSS3 文本阴影 在 CSS3 中,text-shadow 可向文本应用阴影. 您能够规定水平阴影.垂直阴影.模糊距离,以及阴影的颜色: 实例 向标题添加阴影: h1 { text-shadow: ...
- [Intermediate Algorithm] - Steamroller
题目 对嵌套的数组进行扁平化处理.你必须考虑到不同层级的嵌套. 提示 Array.isArray() 测试用例 steamroller([[["a"]], [["b&qu ...
- js 响应事件
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- 【转载】使用JSONObject生成和解析json
1. json数据类型 类型 描述 Number 数字型 String 字符串型 Boolean 布尔型 Array 数组 Object 对象 null 空值 (1)json中不区分整数.小数等类型, ...
- 【双系统】windows 和 Ubuntu 双系统安装
本博客主要讲述如何在已安装windows系统的计算机上安装Ubuntu双系统,涉及系统安装和相应磁盘空间分配等问题. 所需环境: 电脑已安装windows系统 下载Ubuntu16.04系统镜像 ...
- POJ3069 Saruman's Army【贪心】
Saruman the White must lead his army along a straight path from Isengard to Helm's Deep. To keep tra ...
- String使用方式详细总结
1.用双引号创建 2.用new String方式创建 3.双引号相加创建 4.两个new String相加时 5.两个引用相加时 6.双引号加new String创建或者new String加双引号创 ...