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. centos7 Another app is currently holding the yum lock; waiting for it to exit...

    解决方法:rm -rf /var/run/yum.pid 来强行解除锁定,然后你的yum就可以运行了

  2. NOIP2016 天天爱跑步(线段树/桶)

    题目描述 小c同学认为跑步非常有趣,于是决定制作一款叫做<天天爱跑步>的游戏.天天爱跑步是一个养成类游戏,需要 玩家每天按时上线,完成打卡任务. 这个游戏的地图可以看作一一棵包含 N个结点 ...

  3. 关于搭建Session服务器(转载)

    Session服务器配置指南与使用经验 一.摘要 所有Web程序都会使用Session保存数据. 使用独立的Session服务器可以解决负载均衡场景中的Session共享问题.本文介绍.NET平台下建 ...

  4. 如何在同一台机器上安装多个MySQL的实例(转)

    最近由于工作的需要,需要在同一台机器上搭建两个MySQL的实例,(注:已经存在了一个3306的MySQL的实例). 先说下,什么是mysql的多实例,简单的来说就是一台机器上安装了多个mysql的服务 ...

  5. IOS开发UI基础--数据刷新

    IOS开发UI基础--数据刷新 cell的数据刷新包括下面几个方面 加入数据 删除数据 更改数据 全局刷新方法(最经常使用) [self.tableView reloadData]; // 屏幕上的全 ...

  6. 深度学习 Deep Learning UFLDL 最新Tutorial 学习笔记 3:Vectorization

    1 Vectorization 简述 Vectorization 翻译过来就是向量化,各简单的理解就是实现矩阵计算. 为什么MATLAB叫MATLAB?大概就是Matrix Lab,最根本的差别于其它 ...

  7. 学习easyui疑问(三)

    今天我学习easyui中碰到的还有一问题是:怎样创建一个表格? 首先,在easyui中文官网上提供的这样一种定义方式: <!--table--> <table id="tt ...

  8. Valgrind的用法

    Valgrind是执行在Linux上一套基于仿真技术的程序调试和分析工具,它包括一个内核──一个软件合成的CPU,和一系列的小工具,每一个工具都能够完毕一项任务──调试.分析,或測试等. Valgri ...

  9. Log4j 2使用教程 分类: B1_JAVA 2014-07-01 12:26 314人阅读 评论(0) 收藏

    转载自 Blog of 天外的星星: http://www.cnblogs.com/leo-lsw/p/log4j2tutorial.html Log4j 2的好处就不和大家说了,如果你搜了2,说明你 ...

  10. Altium Designer如何设置pcb尺寸