POJ-2151 Check the difficulty of problems---概率DP好题
题目链接:
https://vjudge.net/problem/POJ-2151
题目大意:
ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率
问 每队至少解出一题且冠军队至少解出N道题的概率。
解题思路:
看了题解才恍然大悟,还是做题少没思路。
要求:每队至少解出一题 且 冠军队至少解出N道题的概率
由于冠军队可以不止一队,即允许存在并列冠军
则原来的所求的概率可以转化为:
每队均至少做一题的概率P1 减去 每队做题数均在1到N-1之间的概率P2

注意初始条件,其他递推即可
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn = ;
double p[maxn][];//p[i][j]表示第i个队做出第j题的概率
double dp[maxn][][];//dp[i][j][k]表示第i个队前j道题做出k题的概率
double sum[maxn][];//sum[i][j]表示第i个队伍做出至多k题的概率(前缀和)
int main()
{
int n, m, t;
while(cin >> m >> t >> n && m)
{
for(int i = ; i <= t; i++)
{
for(int j = ; j <= m; j++)
cin >> p[i][j];
}
memset(dp, , sizeof(dp));
memset(sum, , sizeof(sum));
for(int i = ; i <= t; i++)
{
dp[i][][] = p[i][];
dp[i][][] = 1.0 - p[i][];
for(int j = ; j <= m; j++)
{
for(int k = ; k <= j; k++)
{
dp[i][j][k] = dp[i][j - ][k] * ( - p[i][j]) + dp[i][j - ][k - ] * p[i][j];
}
}
}
for(int i = ; i <= t; i++)
{
sum[i][] = dp[i][m][];
for(int j = ; j <= m; j++)
sum[i][j] = sum[i][j - ] + dp[i][m][j];
}
double p1 = , p2 = ;
//p1表示所有队伍至少做出1题的概率
//p2表示所有队伍做题数目在1-n-1之间
for(int i = ; i <= t; i++)
p1 *= (sum[i][m] - sum[i][]),
p2 *= (sum[i][n - ] - sum[i][]);
printf("%.3f\n", p1 - p2);
}
}
POJ-2151 Check the difficulty of problems---概率DP好题的更多相关文章
- POJ 2151 Check the difficulty of problems 概率dp+01背包
题目链接: http://poj.org/problem?id=2151 Check the difficulty of problems Time Limit: 2000MSMemory Limit ...
- [ACM] POJ 2151 Check the difficulty of problems (概率+DP)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4748 ...
- POJ 2151 Check the difficulty of problems (概率DP)
题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 ,求每队至少解出一题且冠军队至少解出N道题的概率. 析:概率DP,dp[i][j][k] 表示第 i 个队伍,前 j 个题,解出 ...
- POJ 2151 Check the difficulty of problems (动态规划-可能DP)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4522 ...
- POJ 2151 Check the difficulty of problems
以前做过的题目了....补集+DP Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K ...
- poj 2151 Check the difficulty of problems(概率dp)
poj double 就得交c++,我交G++错了一次 题目:http://poj.org/problem?id=2151 题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 问 ...
- POJ 2151 Check the difficulty of problems:概率dp【至少】
题目链接:http://poj.org/problem?id=2151 题意: 一次ACM比赛,有t支队伍,比赛共m道题. 第i支队伍做出第j道题的概率为p[i][j]. 问你所有队伍都至少做出一道, ...
- POJ 2151 Check the difficulty of problems (概率dp)
题意:给出m.t.n,接着给出t行m列,表示第i个队伍解决第j题的概率. 现在让你求:每个队伍都至少解出1题,且解出题目最多的队伍至少要解出n道题的概率是多少? 思路:求补集. 即所有队伍都解出题目的 ...
- [POJ2151]Check the difficulty of problems (概率dp)
题目链接:http://poj.org/problem?id=2151 题目大意:有M个题目,T支队伍,第i个队伍做出第j个题目的概率为Pij,问每个队伍都至少做出1个题并且至少有一个队伍做出N题的概 ...
- POJ2157 Check the difficulty of problems 概率DP
http://poj.org/problem?id=2151 题意 :t个队伍m道题,i队写对j题的概率为pij.冠军是解题数超过n的解题数最多的队伍之一,求满足有冠军且其他队伍解题数都大于等于1 ...
随机推荐
- 微信小程序多图上传/朋友圈传图效果【附完整源码】
效果图 部分源代码 js文件: var uploadPicture = require('../Frameworks/common.js') //获取应用实例 const app = getApp() ...
- spring aop execution用法
代码结构: 1. "execution(* com.ebc..*.*(..))" 与 "execution(* com.ebc..*(..))" 2019-0 ...
- 2013 New available ICOM A2 Diagnostic & Programming For BMW ICOM A2+B+C
AUTONUMEN.COM offer best price New ICOM A2 Diagnostic & Programming For BMW ICOM A2+B+C. bmw ico ...
- The 'gridview' module MUST be setup in your Yii configuration file.
解决方法:common的config的main.php中添加 'gridview' => ['class' => 'kartik\grid\Module'], 在vender的compos ...
- maven 环境变量配置
新增变量:MAVEN_HOME:D:\tools\apache-maven-3.52 修改path,在path中新增如下: %MAVEN_HOME\bin%; 注意末尾增加分号 最后,到dos中查看m ...
- appium手机自动化环境搭建
在robotframework环境安装完成的基础上进行如下安装,如果没有安装rfs环境,请先参考robotframework安装文章:Robot Framework的环境搭建 文件下载地址:链接:ht ...
- Golang常用数据结构(对照python)
python golang init get set extend/update find index size loop list list l := list.New() l.PushBack ...
- mysql初期使用全本
mysql mysql前戏 数据库服务器-:运行数据库管理软件 =>pc 数据库管理软件:管理-数据库 => mysql 数据库:用来组织文件/表 => 文件夹 表:用来存放多行内容 ...
- [转]使用jquery dataTable
本文转自:http://blog.csdn.net/llhwin2010/article/details/8663753 jQuery 的插件 dataTables 是一个优秀的表格插件,提供了针对表 ...
- Kudu的概念术语
不多说,直接上干货! Columnar Data Store(列式数据存储) Kudu 是一个 columnar data store(列式数据存储).列式数据存储在强类型列中.由于几个原因,通过适当 ...