题目链接: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. Servlet3.0 jsp跳转到Servlet 出现404错误的路径设置方法

    最近又遇到了这种问题,百度了好久,发现有人说要在action的路径里面写Servlet文件的绝对路径,比如说,单独打开servlet的地址为http://localhost:8080/TomcatTe ...

  2. CSS+DIV 设计一个简单的个人网页界面

    *{ margin:0px; padding:0px; } body{ background:#e5e6d0; } #header,#menu,#banner,#main,#footer{ margi ...

  3. HttpClient方式模拟http请求

    方式一:HttpClient import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.http.*; im ...

  4. php用smtp发送邮件

    php用smtp发送邮件 1.其实用smtp协议发送邮件很简单,用框架或者原生都可以,我们需要用到class.phpmailer.php 和class.smtp.php,大家可以去网上下载. 这是一个 ...

  5. 【Cocos2d-x 3.x】 精灵帧缓存和纹理缓存

    转自泰然网(Cocos2d-x 3.x官方文档):精灵帧缓存:http://www.tairan.com/archives/6378/   纹理缓存: http://www.tairan.com/ar ...

  6. ecshop后台分页浅析

      既然是分页,道理都是一样的,不过ecshop前台分页的函数和后台分页的函数不同,后台分页函数为page_and_size(),在admin/includes/lib_main.php里.都是用aj ...

  7. bash获取properties文件资源

    #!/bin/sh prop_value="" function getProperty() { file=$ prop_key=$ prop_value=`cat $file | ...

  8. C# 模拟按下回车键自动登录

    private void Form1_Load(object sender, EventArgs e) { //this.Show(); this.Activate(); //this.Focus() ...

  9. html选择图片后预览,保存并上传

    html代码:------------------添加-------------------------- accept="image/gif,image/jpeg,image/jpg,im ...

  10. 2016HUAS_ACM暑假集训4C - 递推

    题目大意:给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形. 这里我们可以这样看: 对于行:假如是m单位长度,则长度为1的矩形有m个,长度为2的矩形有m-1个......长度为m的只有1 ...