有 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. 2013年八月GBin1月刊

    2013年八月GBin1月刊 推荐十款来自极客标签的超棒前端特效[第十二期] 本周,我们带来了极客社区推荐的10款前端特效,仍然是非常有趣的小动态效果的页面生成.喜欢的可以直接将我们的在线调试代码插入 ...

  2. 算法笔记_090:蓝桥杯练习 7-1用宏求球的体积(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 问题描述 使用宏实现计算球体体积的功能.用户输入半径,系统输出体积.不能使用函数,pi=3.1415926,结果精确到小数点后五位. 样例输入 一个 ...

  3. Image Based Lighting In UE3

    "IBL"全称为"Image-based Lighint",是一种伪装全局光照的方法.使用该方法可以获得较好的视觉效果并且可以达到实时渲染的目的. 实现的方法之 ...

  4. 06-spring学习-自动装配

    自动装配前面也有写过.这里只做补充 在之前,对于要引用的属性,都必须写上名称, 原始配置: 当要在emp对象里面引用dept对象的时候,需要明确的使用“ref“属性去找到指定的名称,但是这种操作中也可 ...

  5. c#导出到excel的几种解决方案

    (一)传统操作Excel遇到的问题: 1.如果是.NET[使用office组件Microsoft.Iffice.interop.Excel的话],需要在服务器端装Office,且及时更新它,以防漏洞, ...

  6. adb 修改手机代理方式

    一.使用全局命令 设置代理: adb shell settings put global http_proxy 代理IP地址:端口号 如: adb shell settings put global ...

  7. Cocos2d-X中的ZORDER和Tag

    ZORDER:是描写叙述渲染顺序的值,每一个CCNode都有ZORDER,默认是0 ZORDER越大,越后面绘制 假设ZORDER同样.那么看arrival顺序.先增加的节点先绘制 ZORDER仅仅在 ...

  8. DS18B20 crc 算法

    http://blog.csdn.net/pengrui18/article/details/24740973 https://www.maximintegrated.com/cn/app-notes ...

  9. Python 统计代码的行数,Python脚本 统计代码

    # coding=utf-8 import os import time # 需要统计的文件夹或者文件,这是在windows下运行的,如果使用Linux系统可以使用 basedir = '/app/l ...

  10. 如何在mysql下实现事务的提交与回滚

    最近要对数据库的数据进行一个定时迁移,为了防止在执行过程sql语句因为某些原因报错而导致数据转移混乱,因此要对我们的脚本加以事务进行控制. 首先我们建一张tran_test表 CREATE TABLE ...