http://poj.org/problem?id=2151

 
题意 :t个队伍m道题,i队写对j题的概率为pij。冠军是解题数超过n的解题数最多的队伍之一,求满足有冠军且其他队伍解题数都大于等于1的概率。
 
f[i][j][w]表示i队到第j题总共解出w道题的概率.
为了避免重复计数;
pa=所有队伍到最后一道题时的解题数都大于1的概率;
pb=所有队伍到最后一道题时解题数都小于n的概率;
答案为pa-pb.
 
代码如下
 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
const int maxn=;
const double eps=1e-;
const int modn=;
int m,n,t;
double f[maxn][][]={};
double f1[maxn][]={};
double a[maxn][];
int main(){
while(~scanf("%d%d%d",&m,&t,&n)){
memset(f,,sizeof(f));
if(m==&&n==&&t==)break;
for(int i=;i<=t;i++){
for(int j=;j<=m;j++){
scanf("%lf",&a[i][j]);
}
}
double t1=,t2=,t3,t4;
for(int i=;i<=t;i++){
f[i][][]=;
for(int j=;j<=m;j++){
for(int w=;w<=j;w++){
if(j->=w)f[i][j][w]+=f[i][j-][w]*(1.0-a[i][j]);
f[i][j][w]+=f[i][j-][w-]*a[i][j];
}
}
t3=,t4=;
for(int j=;j<=m;j++){
t3+=f[i][m][j];
if(j<n){
t4+=f[i][m][j];
}
}
t1*=t3;t2*=t4;
}
printf("%.3f\n",t1-t2);
}
return ;
}

POJ2157 Check the difficulty of problems 概率DP的更多相关文章

  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 ...

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

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

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

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

  4. [POJ2151]Check the difficulty of problems (概率dp)

    题目链接:http://poj.org/problem?id=2151 题目大意:有M个题目,T支队伍,第i个队伍做出第j个题目的概率为Pij,问每个队伍都至少做出1个题并且至少有一个队伍做出N题的概 ...

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

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

  6. POJ2151Check the difficulty of problems 概率DP

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

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

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

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

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

  9. POJ 2151 Check the difficulty of problems (动态规划-可能DP)

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

随机推荐

  1. 去除UITableView多余的seperator

    UIView *v = [[UIView alloc] initWithFrame:CGRectZero]; [tableView setTableFooterView:v]; [v release] ...

  2. 2017ACM暑期多校联合训练 - Team 2 1009 HDU 60563 TrickGCD (容斥公式)

    题目链接 Problem Description You are given an array A , and Zhu wants to know there are how many differe ...

  3. Sublime text 2/3 SVN插件及使用方法

    Sublime Text是前端利器,作为前端的盆友们已经再熟悉不过了,在项目中经常使用SVN,每次都要切换提交,很麻烦,有了这个SVN插件就很方便了,使用快捷方式提交,更新. Sublime Text ...

  4. 二. Jmeter--关联

    1. 首先建立一个线程组(Thread Group),为什么所有的请求都要加入线程组这个组件呢?不加不行吗?答案当然是不行的.因为jmeter的所有任务都必须由线程处理,所有任务都必须在线程组下面创建 ...

  5. 2017百度春招<不等式排列>

    题目: 度度熊最近对全排列特别感兴趣,对于1到n的一个排列,度度熊发现可以在中间根据大小关系插入合适的大于和小于符号(即 '>' 和 '<' )使其成为一个合法的不等式数列.但是现在度度熊 ...

  6. Linux环境Nginx安装、调试以及PHP安装

    linux版本:64位CentOS 6.4 Nginx版本:nginx1.8.0 php版本:php5.5 1.编译安装Nginx 官网:http://wiki.nginx.org/Install 下 ...

  7. Codeforces 821C Okabe and Boxes(模拟)

    题目大意:给你编号为1-n的箱子,放的顺序不定,有n条add指令将箱子放入栈中,有n条remove指令将箱子移除栈,移出去的顺序是从1-n的,至少需要对箱子重新排序几次. 解题思路:可以通过把栈清空表 ...

  8. Linux Shell基础篇——变量

    一.Shell中的变量 注:这里所说的Shell是Bash Shell,我姑且统称为Shell. Shell中的变量分为用户自定义变量.环境变量.位置参数变量.预定义变量.在Shell中,变量的默认类 ...

  9. 搭建简单的CGI应用程序

    原文来源于<核心编程3>第10章web编程 一.静态文件+脚本文件 1.首先开启cgiweb服务器 python2 -m CGIHTTPServer 8000 看到如下反应 2.服务器目录 ...

  10. 小甲鱼Python笔记(上)

    基于Python 3.4.3 一 二 三 四  基础 print 三版必须加括号,二版不用加 alt + n :上一条语句 alt + p :下一条语句 打印三条hello 没有大括号,用缩进来表示 ...