有 T(1<T<=1000) 支队伍和 M(0<M<=30) 个题目,已知每支队伍 i 解决每道题目 j 的的概率 p[i][j],现在问:每支队伍至少解决一道题,且解题最多的队伍的题目数量不少于 N(0<N<=M) 的概率是多少?

p[i][j]表示第i个队伍做对第j题的概率。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]);
再求出每个队都至少做对 1 道题的概率:ans1 *= 1 - dp[i][m][0];
求出每个队都只做对了 1 ~ n-1 题的概率 ans2即:(把每个队做对 1 ~ n-1 题的概率相加后,并把每个队的结果相乘);
然后两者相减ans1-ans2

 #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int M,T,N;
double p[][];
double dp[][][];
double sum[][];
int main() {
scanf("%d %d %d",&M,&T,&N);
while(M&&N&&T){
memset(p,,sizeof(p));
for(int i=;i<=T;i++){
for(int j=;j<=M;j++){
scanf("%lf",&p[i][j]);
}
}
memset(dp,,sizeof(dp));
for(int i=;i<=T;i++){
dp[i][][]=p[i][];
dp[i][][]=-p[i][]; }
for(int i=;i<=T;i++){
for(int j=;j<=M;j++){
for(int k=;k<=j;k++){
dp[i][j][k]=dp[i][j-][k]*(1.0-p[i][j]);
if(k>) dp[i][j][k]+=dp[i][j-][k-]*p[i][j];
}
}
}
memset(sum,,sizeof(sum));
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 ans1=1.0,ans2=1.0;
for(int i=; i<=T; i++) {
ans1*=sum[i][M]-sum[i][];
ans2*=(sum[i][N-]-sum[i][]);
}
printf("%.3lf\n",ans1-ans2);
scanf("%d %d %d",&M,&T,&N);
} return ;
}
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 5766   Accepted: 2515

Description

Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually expect the contest result satisfy the following two terms: 
1. All of the teams solve at least one problem. 
2. The champion (One of those teams that solve the most problems) solves at least a certain number of problems.

Now the organizer has studied out the contest problems, and through the result of preliminary contest, the organizer can estimate the probability that a certain team can successfully solve a certain problem.

Given the number of contest problems M, the number of teams T, and the number of problems N that the organizer expect the champion solve at least. We also assume that team i solves problem j with the probability Pij (1 <= i <= T, 1<= j <= M). Well, can you calculate the probability that all of the teams solve at least one problem, and at the same time the champion team solves at least N problems?

Input

The input consists of several test cases. The first line of each test case contains three integers M (0 < M <= 30), T (1 < T <= 1000) and N (0 < N <= M). Each of the following T lines contains M floating-point numbers in the range of [0,1]. In these T lines, the j-th number in the i-th line is just Pij. A test case of M = T = N = 0 indicates the end of input, and should not be processed.

Output

For each test case, please output the answer in a separate line. The result should be rounded to three digits after the decimal point.

Sample Input

2 2 2
0.9 0.9
1 0.9
0 0 0

Sample Output

0.972

Check the difficulty of problems - poj 2151 (概率+DP)的更多相关文章

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

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

  2. poj 2151 概率DP(水)

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

  3. POJ 2151 概率DP

    主要的子问题是每一个队伍有一个做出题目的概率,求做出k个题目的概率.简单的简单的组合数DP.想清楚即可. 1: #include <iostream> 2: #include <cs ...

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

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

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

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

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

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

  7. Check the difficulty of problems(POJ 2151)

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

  8. POJ 2151 Check the difficulty of problems

    以前做过的题目了....补集+DP        Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K ...

  9. Check the difficulty of problems

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

随机推荐

  1. Linux命令之编辑

    vi是终端命令行里功能最强的文本编辑器了,但眼下须要用到的仅仅是文本编辑功能.与GCC.make等工具的整合应用如今还不须要,所以操作难度不大,习惯就好. Linux发行版所带的一般不是vi,而是vi ...

  2. 如何使用Apache设置404页面

    方法一:[.htaccess文件配置404] 网上大部分解决办法是:首先你要开启Apache的rewrite_module模块,支持.htaccess,然后在网站根目录建立.htaccess文件(或已 ...

  3. vue - node_modules

    详情见:node_modules导包机制 在打包或者结束项目时,这个文件夹(node_modules)不应该被打包. 你应该打包其它的文件,如果要运行(直接用以下命令安装即可,它会根据package. ...

  4. Android 微信支付,授权,分享回调区分记录

    我们做项目中避免不了和微信打交道,其中最常用的也就是授权登录与分享和支付了. 本篇文章记录这三个功能同时使用的时候,回调怎么来区分.因为每个功能都有自己的回调状态.前期集成与发送,资料很多了就不在这里 ...

  5. ZK框架笔记5、事件

            事件是org.zkoss.zk.ui.event.Event类,它通知应用程序发生了什么事情.每一种类型的事件都由一个特定的类来表示.         要响应一个事件,应用程序必须为事 ...

  6. Android五天乐(第二天)Activity跳转与传输数据,Fragment

    1 Activity的生命周期 activity在生命周期内共同拥有执行.暂停,和停止三种状态.每次发生状态转换时,都有一个Activity方法将状态改变的消息通知给activity.activity ...

  7. 【Linux】通过传入变量进行数学运算

    一个简单的sum求和 #! /bin/bash ## For get the sum of tow numbers ## Writen by Qinys ## Date:2018-06-26 a=1 ...

  8. 【PPT】PPT倒计时动画的制作方法 5.4.3.2.1...

    制作步骤: 1.输入数字 在PPT空白页面中插入横排文本框,输入数字54321,并修改数字字体和大小. 2.修改数字的间距,让数字重叠在一起 字体间距 - 其他间距 - 紧缩 - 输入 150 3.选 ...

  9. PL/SQL 美化器不能解析文本

    1.问题:PL/SQL美化器不能解析文本 原始sql语句如下: CREATE OR REPLACE VIEW V_GGXZBM AS SELECT XZBM,XZMC,CASE WHEN PARENT ...

  10. WebApi接口传参不再困惑(4):传参详解

    前言:还记得刚使用WebApi那会儿,被它的传参机制折腾了好久,查阅了半天资料.如今,使用WebApi也有段时间了,今天就记录下API接口传参的一些方式方法,算是一个笔记,也希望能帮初学者少走弯路.本 ...