Check the difficulty of problems
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 4403   Accepted: 1941

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
/*题意:
ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率
问 每队至少解出一题且冠军队至少解出N道题的概率。 分析:
对于须要求得概率比較easy想到:
如果p1为每一个队至少解出一题的概率,这个easy算出。
如果p2为每一个队至少解出一题可是不超过n-1题的概率
所以终于答案为:p1-p2
如今问题是怎样求出p2? 如果dp[i][j]表示第i个队解出的题目<=j的概率
则dp[i][j]=解出1题+解出2题+...解出j题的概率
如今问题转化为怎样求解出1。2,3...k题的概率
如果x[i][j][k]表示第i个队在前j题解出k题的概率
则:
x[i][j][k]=x[i][j-1][k-1]*p[i][j]+x[i][j-1][k]*(1-p[i][j]);
所以x[i][M][k]表示的就是第i个队解出k题的概率
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define INF 99999999
typedef long long LL;
using namespace std; const int MAX=1000+10;
const int N=30+10;
int m,t,n,index;
double x[2][N],dp,p[MAX][N]; int main(){
while(cin>>m>>t>>n,m+t+n){
double p1=1,p2=1,temp=1;
for(int i=1;i<=t;++i){
temp=1;
for(int j=1;j<=m;++j){cin>>p[i][j];temp=temp*(1-p[i][j]);}
p1=p1*(1-temp);//1-temp表示至少解出一道题
}
for(int i=1;i<=t;++i){
index=0;
memset(x,0,sizeof x);//初始化前0个解出1~m为0
x[0][0]=1;//前0个解出0个为1
for(int j=1;j<=m;++j){
index=index^1;
for(int k=1;k<=m;++k){
x[index][k]=p[i][j]*x[index^1][k-1]+(1-p[i][j])*x[index^1][k];
}
x[index][0]=x[index^1][0]*(1-p[i][j]);//表示前j道题做出0题的概率
}
dp=0;//dp表示第i队解出题目为1~n-1的概率
for(int j=1;j<=n-1;++j)dp+=x[index][j];
p2=p2*dp;//p2表示解出1~n-1题的概率
}
printf("%.3f\n",p1-p2);
}
return 0;
}

poj2151之概率DP的更多相关文章

  1. Codeforces 28C [概率DP]

    /* 大连热身D题 题意: 有n个人,m个浴室每个浴室有ai个喷头,每个人等概率得选择一个浴室. 每个浴室的人都在喷头前边排队,而且每个浴室内保证大家都尽可能均匀得在喷头后边排队. 求所有浴室中最长队 ...

  2. HDU 4405 Aeroplane chess (概率DP)

    题意:你从0开始,要跳到 n 这个位置,如果当前位置是一个飞行点,那么可以跳过去,要不然就只能掷骰子,问你要掷的次数数学期望,到达或者超过n. 析:概率DP,dp[i] 表示从 i  这个位置到达 n ...

  3. POJ 2096 Collecting Bugs (概率DP)

    题意:给定 n 类bug,和 s 个子系统,每天可以找出一个bug,求找出 n 类型的bug,并且 s 个都至少有一个的期望是多少. 析:应该是一个很简单的概率DP,dp[i][j] 表示已经从 j ...

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

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

  5. 概率DP light oj 1030

    t组数据 n块黄金 到这里就捡起来 出发点1 到n结束  点+位置>n 重掷一次 dp[i] 代表到这里的概率 dp[i]=(dp[i-1]+dp[i-2]... )/6  如果满6个的话 否则 ...

  6. hdu 4050 2011北京赛区网络赛K 概率dp ***

    题目:给出1-n连续的方格,从0开始,每一个格子有4个状态,左右脚交替,向右跳,而且每一步的步长必须在给定的区间之内.当跳出n个格子或者没有格子可以跳的时候就结束了,求出游戏的期望步数 0:表示不能到 ...

  7. [转]概率DP总结 by kuangbin

    概率类题目一直比较弱,准备把kuangbin大师傅总结的这篇题刷一下! 我把下面的代码换成了自己的代码! 原文地址:http://www.cnblogs.com/kuangbin/archive/20 ...

  8. SGU 422 Fast Typing(概率DP)

    题目大意 某人在打字机上打一个字符串,给出了他打每个字符出错的概率 q[i]. 打一个字符需要单位1的时间,删除一个字符也需要单位1的时间.在任意时刻,他可以花 t 的时间检查整个打出来的字符串,并且 ...

  9. HDU 4050 wolf5x(动态规划-概率DP)

    wolf5x Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

随机推荐

  1. C#打印日志的小技巧(转)

    https://www.cnblogs.com/jqg-aliang/p/5234206.html 打印日志的函数 开发中输出日志必不可少,在C#中输出多个不同类型参数的时候,需要连接符累加输出,很是 ...

  2. 【Codeforces Round #451 (Div. 2) C】Phone Numbers

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map<string,vector > dic;模拟就好. 后缀.翻转一下就变成前缀了. 两重循环剔除这种情况不输出就 ...

  3. 又一次认识java(一) ---- 万物皆对象

    假设你现实中没有对象.至少你在java世界里会有茫茫多的对象,听起来是不是非常激动呢? 对象,引用,类与现实世界 现实世界里有许很多多的生物,非生物,跑的跳的飞的,过去的如今的未来的,令人眼花缭乱.我 ...

  4. Moodle 中文 API 之 文件管理API

    File API  文件管理 文件夹 1. 概述 2. 文件域 2.1 命名文件域 3. 提供文件给用户 4. 从用户那获取文件 5. 样例 5.1 浏览文件 5.2 移动文件 5.3 文件列表 5. ...

  5. Beginning iOS Programming

    Beginning iOS Programming 2014年 published by Wrox

  6. LocationOnScreen-控件在手机屏幕中的位置坐标

    我们可以通过如下的方法获得某个控件在屏幕中的绝对坐标 代码如下: private int[] mHistoryDisplayButtonLocation; private int mHistoryDi ...

  7. Windows Route 路由表命令整理

    Windows Route 路由表命令 在本地 IP 路由表中显示和修改条目. 语法 route [-f] [-p] [Command [Destination] [mask Netmask] [Ga ...

  8. 1.1 Introduction中 Distribution官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Distribution 分布式(Distribution) The partiti ...

  9. 水题ing

    T1: https://www.luogu.org/problemnew/show/P1724幻想乡,东风谷早苗是以高达控闻名的高中生宅巫女.某一天,早苗终于入手了最新款的钢达姆模型.作为最新的钢达姆 ...

  10. 在react底下安装环境

    1.在react底下安装环境 Image.png Image.png 2.新建一个文件夹 Image.png 3.配置入口文件redux:staticRoot+'/redux/app' Image.p ...