http://poj.org/problem?id=2151   
                                                           Check the difficulty of problems
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 4873   Accepted: 2131

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
分析:求保证每个队至少做对一题,冠军队做对n个题的概率。
保证每个队至少做对一题,冠军队做对n个题的概率=每个队至少做对一道题-没有一个队做到n到题。(每个队最多做了n-1个题),
dp[i][j][k]表示第i个对做到j题,目前做对了k题。
dp[i][j[k]=dp[i][j-1][k]*(1-a[i][j])+dp[i][j-1][k-1]*a[i][j];
s[i][k]表示i对至少做对了k题的概率
注意边界。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
double dp[][][];
int main()
{
int m,t,n,i,j,k;
double a[][],cnt,ans,sum,s[][];
while(~scanf("%d%d%d",&m,&t,&n))
{
memset(dp,,sizeof(dp));
memset(s,,sizeof(s));
cnt=;
ans=;
sum=;
if(m==&&t==&&n==)
break;
for(i=;i<=t;i++)
{
for(j=;j<=m;j++)
{
scanf("%lf",&a[i][j]) ;
cnt*=(-a[i][j]);
}
ans*=(-cnt);
cnt=;
}
for(i=;i<=t;i++)
{
dp[i][][]=-a[i][];
dp[i][][]=a[i][];
for(j=;j<=m;j++)
dp[i][j][]=dp[i][j-][]*(-a[i][j]);
for(j=;j<=m;j++)
{
for(k=;k<=j;k++)
{
dp[i][j][k]=dp[i][j-][k]*(-a[i][j])+dp[i][j-][k-]*a[i][j]; }
}
for(k=;k<=n-;k++)
s[i][n-]+=dp[i][m][k];
}
for(i=;i<=t;i++)
{
sum*=s[i][n-]; }
printf("%.3lf\n",ans-sum); }
return ;
}

poj 2151的更多相关文章

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

    poj double 就得交c++,我交G++错了一次 题目:http://poj.org/problem?id=2151 题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 问 ...

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

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

  3. POJ 2151 Check the difficulty of problems:概率dp【至少】

    题目链接:http://poj.org/problem?id=2151 题意: 一次ACM比赛,有t支队伍,比赛共m道题. 第i支队伍做出第j道题的概率为p[i][j]. 问你所有队伍都至少做出一道, ...

  4. POJ 2151 Check the difficulty of problems

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

  5. Check the difficulty of problems(POJ 2151)

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

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

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

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

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

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

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

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

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

随机推荐

  1. MES项目中出现的一个事务嵌套的使用场景

    昨天在MES项目中,需要在业务逻辑的几个关键点记录错误信息,需要把错误信息写入数据表. 但是由于整个业务逻辑都是包在一个事务模板里面的 比如这样的: WhhTransactionTemplate tr ...

  2. SQL SERVER 高级编程 - 自定义函数 拾忆

    每个人都很忙,但是花10分钟复习下,总结下基础东西还是很有益处的. 背景: 总结一句,使用简便,还能递归,是的SQL更简洁,相对比一大堆的关联语句,而且关联一大堆还不一定实现特定功能.而且共用部分可以 ...

  3. AUTOTRACE Statistics常用列解释

    AUTOTRACE Statistics常用列解释 序号 列名 解释 1 db block gets 从buffer cache中读取的block的数量 2 consistent gets 从buff ...

  4. while loading persisted sessions 异常解决方法

    一直用tomcat一段时间都正常无事,最近一次启动tomcat就发生以下异常: 严重: IOException while loading persisted sessions: java.io.EO ...

  5. tomcat环境变量配置

    先下载tomcat的压缩包(绿色版),解压到C盘目录下即可. 在系统坏境中配置(高级系统设置>环境变量>系统变量) 新建变量名:CATALINA_HOME,变量值:C:\apache-to ...

  6. linux系统 web在线日志分析

    线上环境出现问题时,不能像本地环境一样,断点查找问题,只有根据日志分析来定位问题,当然有资深的经验也是可以的,哈哈. 最基本的就是cat命令,可以通过cat filename,来查看文件全部内容, & ...

  7. c、c++混编实现查询本地IP地址

    一.思路 1.要想得到本地IP地址,可以通过本机名来查询,所以首先得得到本机名. 2.牵涉到IP地址,首先想到牵涉到网络协议,因此得加载套接字协议,所以先使用WSAStartup函数完成对Winsoc ...

  8. CSS3圆角(border-radius)

    CSS3中的border-radius支持IE9+,chrome,firefox 2.3+,以及safari3.2+浏览器. border-radius可直接使用,无需加前缀(注意:firefox13 ...

  9. cmd 进入不同的驱动盘及上下级目录

    “开始”=>“运行”,输入”cmd“,此时进入的是系统管理员的等待命令 如果想进入相应的盘符,如 d 盘,则输入 cd d:\,然后再次输入 d: 即可进入 d: 盘,输入两次相当于第二在是询问 ...

  10. Struts2常规配置

    默认配置文件名:struts.xml   WEB-INF/classes下(放到src下) Struts2的有效常量可以查看    org\apache\struts2 下的    default.p ...