[POJ2151]Check the difficulty of problems (概率dp)
题目链接:http://poj.org/problem?id=2151
题目大意:有M个题目,T支队伍,第i个队伍做出第j个题目的概率为Pij,问每个队伍都至少做出1个题并且至少有一个队伍做出N题的概率。
先定义状态dp[i][j][k],代表第i支队伍从前j个题目里正好做出k题的概率。
有:dp[i][j][k] = dp[i][j-1][k]*(1-p[i][j]) + dp[i][j-1][k-1]*p[i][j];
然后设f[i]为前i支队伍里,每队至少做出一个题并且至少有一个队伍做出N题的概率。
那么f[i] = f[i-1]*(第i支队伍做出不少于1题的概率) + (1-f[i-1]-存在队伍没做出题的概率)*(第i支队伍做了不少于N题的概率)
上面这个是个全概率公式
于是乎:
///#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <numeric>
#include <iterator>
#include <iostream>
#include <cstdlib>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <cctype>
using namespace std;
#define PB push_back
#define MP make_pair
#define SZ size()
#define ST begin()
#define ED end()
#define CLR clear()
#define ZERO(x) memset((x),0,sizeof(x))
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
const double EPS = 1e-; const int MAX_T = ;
const int MAX_M = ; int M,T,N;
double p[MAX_T][MAX_M],f[MAX_T],any[MAX_T],dp[MAX_T][MAX_M][MAX_M]; int main(){
while( ~scanf("%d%d%d",&M,&T,&N), M!=&&T!=&&N!= ) {
ZERO(dp);
ZERO(f);
ZERO(any);
for(int i=;i<=T;i++) {
for(int j=;j<=M;j++) {
scanf("%lf",&p[i][j]);
}
}
for(int i=;i<=T;i++){
dp[i][][] = 1.0;
for(int j=;j<=M;j++) {
dp[i][j][] = dp[i][j-][]*(-p[i][j]);
}
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 j=;j<=M;j++){
for(int k=;k<=M;k++){
dp[i][j][k] += dp[i][j][k-];
}
}
} f[] = 0.0;
any[] = 1.0;
for(int i=;i<=T;i++){
any[i] = any[i-]*(1.0-dp[i][M][]);
}
for(int i=;i<=T;i++){
any[i] = 1.0 - any[i];
}
any[] = 0.0; for(int i=;i<=T;i++){
f[i] = f[i-]*(dp[i][M][M]-dp[i][M][]) + (1.0-f[i-]-any[i-])*(dp[i][M][M]-dp[i][M][N-]);
} printf("%.3f\n",f[T]);
}
return ;
}
[POJ2151]Check the difficulty of problems (概率dp)的更多相关文章
- [poj2151]Check the difficulty of problems概率dp
解题关键:主要就是概率的推导以及至少的转化,至少的转化是需要有前提条件的. 转移方程:$dp[i][j][k] = dp[i][j - 1][k - 1]*p + dp[i][j - 1][k]*(1 ...
- 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 个题,解出 ...
- POJ2157 Check the difficulty of problems 概率DP
http://poj.org/problem?id=2151 题意 :t个队伍m道题,i队写对j题的概率为pij.冠军是解题数超过n的解题数最多的队伍之一,求满足有冠军且其他队伍解题数都大于等于1 ...
- POJ2151Check the difficulty of problems 概率DP
概率DP,还是有点恶心的哈,这道题目真是绕,问你T个队伍.m个题目.每一个队伍做出哪道题的概率都给了.冠军队伍至少也解除n道题目,全部队伍都要出题,问你概率为多少? 一開始感觉是个二维的,然后推啊推啊 ...
- POJ-2151 Check the difficulty of problems---概率DP好题
题目链接: https://vjudge.net/problem/POJ-2151 题目大意: ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 问 每队至少解出一题且冠军队至少解出N ...
- poj 2151Check the difficulty of problems<概率DP>
链接:http://poj.org/problem?id=2151 题意:一场比赛有 T 支队伍,共 M 道题, 给出每支队伍能解出各题的概率~ 求 :冠军至少做出 N 题且每队至少做出一题的概率~ ...
- 【POJ】2151:Check the difficulty of problems【概率DP】
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8903 ...
随机推荐
- imshow() displays a white image for a grey image
Matlab expects images of type double to be in the 0..1 range and images that are uint8 in the 0..255 ...
- linux sed和awk的区别
awkawk是一种程序语言,对文档资料的处理具有很强的功能.awk擅长从格式化报文或从一个大的文本文件中抽取数据.awk的命令格式为:awk [-F filed-separator] “command ...
- GWAS Simulation
comvert hmp to ped1, ped2, map fileSB1.ped, SB2.ped, SB.map 1, choose 20 markers for 30 times(WD: /s ...
- java问题排查可能用到的一些命令
1. jmap查询jvm内存使用情况 -heap :打印jvm heap的情况 -histo: 打印jvm heap的直方图.其输出信息包括类名,对象数量,对象占用大小. -histo:live : ...
- MFC下OpenGL入门(可以用)
MFC下OpenGL入门 源文件 1, 建一工程文件,我这里命名为first,现在first工程里面我们没有添加任何东西,所有的东西都是MFC自动帮我们创建的. 2, 添加链接库.这一步很关键.打开菜 ...
- iOS 9正式版开始推送 升级机型非常广泛
北京时间今日零时,苹果正式推送了iOS9,对于iPhone和iPad来说这一版系统升级都有很多重要改进,而升级的机型也非常宽泛,甚至连2011年的iPad 2与iPhone 4s都获得了支持,所以广大 ...
- find和grep的区别
find命令:在系统当中搜索符合条件的文件名,如果需要匹配,使用通配符匹配,通配符是完全匹配. grep命令:在文件当中搜索符合条件的字符串,如果需要匹配,使用正侧表达式匹配 正侧表达式是包含匹配.
- IOS 线程处理 子线程
IOS 线程处理 子线程的启动与结束 技术交流新QQ群:414971585 IOS中,如果要在主线程中启动一个子线程,可以又两种方法: [NSThread detachNewThreadSelec ...
- {part1}DFN+LOW(tarjan)割点
什么是jarjan? 1)求割点 定义:在无向连通图中,如果去掉一个点/边,剩下的点之间不连通,那么这个点/边就被称为割点/边(或割顶/桥). 意义:由于割点和割边涉及到图的连通性,所以快速地求出割点 ...
- Opera浏览器导出收藏到Chrome,和几个Chrome的一些小技巧
Opera浏览器还是不错的,但是用着不是特别爽,老是感觉怪怪的,也说不上来哪里不好. 还是换回了Chrome浏览器,Chrome浏览器有一个让我念念不忘的地方,就是收藏夹会自动显示,当打开网页之后,又 ...