以前做过的题目了。。。。补集+DP

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

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

Source

POJ Monthly,鲁小石

 #include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int M,T,N;
double a[][][],s[][],p1,pn,solve[][]; int main()
{
while(~scanf("%d%d%d",&M,&T,&N))
{
if((M||T||N)==) break;
for(int i=;i<=T;i++) for(int j=;j<=M;j++) scanf("%lf",&solve[i][j]);
memset(a,,sizeof(a)); memset(s,,sizeof(s));
for(int i=;i<=T;i++)
{
a[i][][]=;
for(int j=;j<=M;j++)
{
a[i][j][]=a[i][j-][]*(-solve[i][j]);
}
}
for(int i=;i<=T;i++)
{
for(int j=;j<=M;j++)
{
for(int k=;k<=j;k++)
{
a[i][j][k]=a[i][j-][k-]*solve[i][j]+a[i][j-][k]*(-solve[i][j]);
}
}
}
for(int i=;i<=T;i++)
{
s[i][]=a[i][M][];
for(int j=;j<=M;j++)
{
s[i][j]=s[i][j-]+a[i][M][j];
}
}
p1=pn=.;
for(int i=;i<=T;i++)
{
p1*=s[i][M]-s[i][];
pn*=s[i][N-]-s[i][];
}
printf("%.3lf\n",p1-pn);
}
return ;
}

POJ 2151 Check the difficulty of problems的更多相关文章

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  8. 【POJ】2151 Check the difficulty of problems

    http://poj.org/problem?id=2151 题意:T个队伍M条题目,给出每个队伍i的每题能ac的概率p[i][j],求所有队伍至少A掉1题且冠军至少A掉N题的概率(T<=100 ...

  9. Check the difficulty of problems(POJ 2151)

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

随机推荐

  1. CSS基础知识真难啊-position-relative-absolute

    http://blog.csdn.net/libertea/article/details/11662661 -----------position:relative:生成相对定位的元素,相对于其正常 ...

  2. 【翻译自nikic大神】PHP中原生类型的方法

    引言 第一次,翻译别人的文章,用四级英语的水平来翻译~~囧,可能有很多不太恰当的地方,尽管拍砖(有些地方实在想不到恰当的翻译,我同时贴出了原文和自己很low的翻译). 翻译这篇文章用了我3个晚上一个中 ...

  3. List多对多的查询应用

    /** * @param param * @author mercy 查询主副产品(主副产品是多对多的关系) * @return */ public String queryProductSpecAt ...

  4. CentOS解决因python升级导致的中文输入法无法正常使用的问题

    /usr/libexec/ibus-ui-gtk /usr/ bin/ibus-setup /usr/libexec/ibus-engine-table 将以上三个文件中的 “exec python” ...

  5. Codeforces 711E ZS and The Birthday Paradox

    传送门 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output st ...

  6. POJ 2533 Longest Ordered Subsequence(最长上升子序列(NlogN)

    传送门 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subseque ...

  7. 深度剖析Linux与Windows系统的区别,新手必读!

    当我们每个人接触Linux之前,应该先接触的都是windows吧?但我们一般接触Linux后,习惯linux的管理和使用方法后,我们再回过头再来使用windows的时候,内心其实是拒绝的.我们会觉得图 ...

  8. Mysql学习笔记(一)

    技术的王国太过迷人,我刚从事IT就被各种技术所引诱迷惑,什么都想学.我还算言而有信的那一类人,还好有一丁点毅力,于是各种东西都沾染了一点.但是这种遍地开花的情况实在和我的智商不匹配.我没有那么多的精力 ...

  9. 常见linux命令释义(第一天)

    快到中午吃饭了,然后忽然想起来samba里面没有添加用户.于是乎,就玩弄起了samba. Samba三下五除二就安装好了,想想window里面不断的点击下一步,还要小心提防各种隐藏再角落里的绑定软件. ...

  10. iOS - Availability.h

    >for 'dispatch' application inner to begin note `#include <Availability.h>` These macros ar ...