题目链接: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)的更多相关文章

  1. [poj2151]Check the difficulty of problems概率dp

    解题关键:主要就是概率的推导以及至少的转化,至少的转化是需要有前提条件的. 转移方程:$dp[i][j][k] = dp[i][j - 1][k - 1]*p + dp[i][j - 1][k]*(1 ...

  2. POJ 2151 Check the difficulty of problems 概率dp+01背包

    题目链接: http://poj.org/problem?id=2151 Check the difficulty of problems Time Limit: 2000MSMemory Limit ...

  3. [ACM] POJ 2151 Check the difficulty of problems (概率+DP)

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4748   ...

  4. POJ 2151 Check the difficulty of problems (概率DP)

    题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 ,求每队至少解出一题且冠军队至少解出N道题的概率. 析:概率DP,dp[i][j][k] 表示第 i 个队伍,前 j 个题,解出 ...

  5. POJ2157 Check the difficulty of problems 概率DP

    http://poj.org/problem?id=2151   题意 :t个队伍m道题,i队写对j题的概率为pij.冠军是解题数超过n的解题数最多的队伍之一,求满足有冠军且其他队伍解题数都大于等于1 ...

  6. POJ2151Check the difficulty of problems 概率DP

    概率DP,还是有点恶心的哈,这道题目真是绕,问你T个队伍.m个题目.每一个队伍做出哪道题的概率都给了.冠军队伍至少也解除n道题目,全部队伍都要出题,问你概率为多少? 一開始感觉是个二维的,然后推啊推啊 ...

  7. POJ-2151 Check the difficulty of problems---概率DP好题

    题目链接: https://vjudge.net/problem/POJ-2151 题目大意: ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 问 每队至少解出一题且冠军队至少解出N ...

  8. poj 2151Check the difficulty of problems<概率DP>

    链接:http://poj.org/problem?id=2151 题意:一场比赛有 T 支队伍,共 M 道题, 给出每支队伍能解出各题的概率~  求 :冠军至少做出 N 题且每队至少做出一题的概率~ ...

  9. 【POJ】2151:Check the difficulty of problems【概率DP】

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8903   ...

随机推荐

  1. TextRank 自动文摘

    前不久做了有关自动文摘的学习,采用方法是TextRank算法,整理和大家分享. 一. 关于自动文摘 利用计算机将大量的文本进行处理,产生简洁.精炼内容的过程就是文本摘要,人们可通过阅读摘要来把握文本主 ...

  2. 创建html模板

    打开写好的html 复制  在页面上右击------属性  --会出现下面情况

  3. ionic中的service简单写法

    在service中写服务 服务名叫feedService .service('feedService',function($ionicLoading,$q,$http){ return{ //获取反馈 ...

  4. C# 之泛型详解

    转自牛人博客:http://www.blogjava.net/Jack2007/archive/2008/05/05/198566.html 鄙人才疏学浅,经常遇到泛型,一知半解,用的时候也是模糊不清 ...

  5. 99乘法表(bash)

    awk方式: # awk 'BEGIN{for(i=1;i<=9;i++){for(j=1;j<=i;j++){printf j"x"i"="i*j ...

  6. php 添加钩子实例

    <?php/*定义钩子函数*/function add($hook,$actionFunc){    global $emHooks;    if(isset($emHooks[$hook])) ...

  7. springMvc3.0.5搭建全程 (转)

    用了大半年的Spring MVC3.0,用着感觉不错.简单写一个搭建Spring MVC3.0的流程(以Spring3.0.5为列),数据库交互使用spring JDBC Template,附件有项目 ...

  8. 手写json

    json的意思是JavaScript 对象表示法 '{"0":0,"b":[3,4,5],"c":"0","d ...

  9. php excel读取

    当然首先要判断是否有文件和文件类型,接着把文件保存到某个路径中 /** * 读取excel数据 * @author Red * @date * @param $filename 文件所在路径+文件名 ...

  10. 分析案例:应用服务无响应,任务管理器中发现大量w3wp僵尸进程----等待异构系统WebService返回值

    问题描述:       某二次开发的项目反馈,不定期出现应用服务器无响应的情况,登录服务器发现任务管理器中有大量的w3wp僵尸进程. 分析过程: 针对同一进程每隔15秒抓取dump,连续抓取3个,对比 ...