​​​​题干:

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道题的概率。

解题报告:

假设ans1为每个队至少解出一题的概率。

假设ans2为每个队解出的题数均在 [1.n-1] 之间的概率。

这样最终答案就是ans1-ans2。

ans1可以在读入的数据中预处理出来,ans2通过dp求解。

dp[i][j][k]表示第i个队在第j个题中解出k个题的概率。
求出后累加一下就好了。注意别忘dp[][j][0]需要单独处理。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define FF first
#define SS second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;
int m,t,n;//m<=30,t<=1000
double p[1005][33];
double dp[1005][33][33];//dp[i][j][k]第i个队在第j个题中解出k个题的概率
double po,ans1,ans2;//ans1是所有人都做出一个题的概率
int main()
{while(~scanf("%d%d%d",&m,&t,&n) && m+t+n) {ans1=ans2=1;for(int i = 1; i<=t; i++) {po=1;for(int j = 1; j<=m; j++) scanf("%lf",&p[i][j]),po *= (1-p[i][j]);ans1 *= (1-po);}for(int i = 1; i<=t; i++) {dp[i][0][0]=1;for(int j = 1; j<=m; j++) {dp[i][j][0] = dp[i][j-1][0]*(1-p[i][j]);for(int k = 1; k<=m; k++) dp[i][j][k] = dp[i][j-1][k]*(1-p[i][j]) + dp[i][j-1][k-1]*p[i][j];}}for(int i = 1; i<=t; i++) {po=0;for(int j = 1; j<=n-1; j++) po += dp[i][m][j];ans2 *= po;}printf("%.3f\n",ans1-ans2);}return 0 ;
}

【POJ - 2151】Check the difficulty of problems(概率dp)相关推荐

  1. Check the difficulty of problems (概率dp求概率)

    Check the difficulty of problems POJ - 2151 大致题意: m个问题,t个队伍,要求冠军队伍至少解决n个问题,给出每个队伍解决每个问题的概率 求每一个队至少解决 ...

  2. POJ 2151 Check the difficulty of problems (概率dp)

    题意:给出m.t.n,接着给出t行m列,表示第i个队伍解决第j题的概率. 现在让你求:每个队伍都至少解出1题,且解出题目最多的队伍至少要解出n道题的概率是多少? 思路:求补集. 即所有队伍都解出题目的 ...

  3. poj 2151 Check the difficulty of problems

    题意:有m到题,t个队伍,给出第 i 支队作出 第 j 道题的概率 Pij.求每个队至少作出一道题,作出最多的那个队伍至少作出 n 道题的概率. dp[i][j][k]表示第 i 支队前 j 道题作出 ...

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

    题目链接:http://poj.org/problem?id=2151 组合数做肯定超时,容易看出是DP.f[i][j]表示某个队的前j个题目做出i个题目的概率,则f[i][j]=f[i][j-1]* ...

  5. Check the difficulty of problems - poj 2151 (概率+DP)

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

  6. [POJ2151]Check the difficulty of problems(概率DP)

    传送门 每个队之间是独立的 f[i][j]表示当前队伍前i个题答对j个的概率 满足条件的概率 == 全部方案(除去答对0)的概率 - 不满足条件的概率(每个队伍答对1~n-1) #include &l ...

  7. 【POJ - 3744】Scout YYF I(概率dp,矩阵快速幂优化dp)

    题干: 题目大意: 在一条不满地雷的路上(无限长),你现在的起点在1处.在N个点处布有地雷,1<=N<=10.地雷点的可能坐标范围:[1,100000000]. 每次前进p的概率前进一步, ...

  8. 【原创】概率DP总结 by kuangbin

    概率DP主要用于求解期望.概率等题目. 转移方程有时候比较灵活. 一般求概率是正推,求期望是逆推.通过题目可以体会到这点. 首先先推荐几篇参考的论文: <信息学竞赛中概率问题求解初探> & ...

  9. poj 3071 Football(概率dp)

    http://poj.org/problem? id=3071 大致题意:有2^n个足球队分成n组打比赛.给出一个矩阵a[][],a[i][j]表示i队赢得j队的概率.n次比赛的流程像这样France ...

最新文章

  1. 又一位先驱陨落:伯特·萨瑟兰去世,他参与创造互联网、Java、图形界面PC、微处理器,也是明智的实验室领袖...
  2. 傅里叶变化的本质:复数的实部和虚部的对应关系
  3. 软考-信息系统项目管理师-项目合同管理
  4. ASP.NET Core 跨平台图形验证码实现
  5. LeetCode 1176. 健身计划评估(滑动窗口)
  6. 2013计算机系统导论,计算机系统导论2013期末(20页)-原创力文档
  7. html盒子模型子元素怎么水平占满父元素_前端面试常考问题之css盒模型
  8. python3.5 pip安装_用python3.5 pip安装Numpy
  9. 非常好用的终端命令,稀饭~
  10. python简单代码示例-python3简单代码示例
  11. airflow实现Java定时任务,AirFlow定时调度执行Talend ETL任务
  12. 区间DP例题(持续更新)
  13. 任职母校!C9,迎来新副校长!
  14. 5G LTE窄带物联网(NB-IoT)7
  15. 知行之桥2021版账号密码修改和重置指南
  16. 抖音,B站,小红书三大平台品牌投放特征与建议
  17. gym101908 F. Music Festival(状压dp)
  18. 数据结构--------课后题
  19. JS(javascript) 将网站加入收藏夹
  20. 我国支付工具主要有哪几种

热门文章

  1. Android-Animations的使用大全之二:Frame Animation和其他
  2. stub 和 skeleton 的讲解,自己实现一个stub和skeleton程序
  3. [Leedcode][JAVA][第236题][二叉树的公共祖先][后序遍历][BFS]
  4. [剑指offer][JAVA]面试题[51][数组中的逆序对][归并排序]
  5. wordpress functions.php 在哪,在functions.php中定义变量并在WordPress中的函数钩子中访问它们...
  6. mysql binlog 备份_做好mysql运维,必须熟练掌握备份和恢复,实战一次不行多来几次...
  7. mysql 添加唯一索引_浅谈Mysql索引
  8. 怎么检查计算机网络是连接,怎么检测网络打印机是否与电脑连接成功【检测方法】...
  9. sql每个月每个人的花销占比_11月:每个认真生活的人,都值得被认真对待
  10. MATLAB中BP神经网络用于回归拟合算法实现(另附GRNN代码)