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

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,鲁小石
 
概率dp
开始理解错了题意,弄了半天也没搞出来,后来理解完了啦,发现概率都忘了。
然后补概率。
设A = “所有队都至少做完一题”, B = “至少存在一个队做完不少于n题”;
P(A) = P(A(B + !B)) = P(AB) + P(A!B);
P(AB) = P(A) - P(A!B);
 
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
#define ll long long
#define _cle(m, a) memset(m, a, sizeof(m))
#define repu(i, a, b) for(int i = a; i < b; i++)
#define MAXN 1005
double p[MAXN][];
double d[MAXN][][];
double s[MAXN][];
int main()
{
int m, t, n;
while(~scanf("%d%d%d", &m, &t, &n) && (m + t + n))
{
for(int i = ; i < t; i++)
for(int j = ; j <= m; j++)
scanf("%lf", &p[i][j]);
_cle(d, ); for(int i = ; i < t; i++) {
d[i][][] = 1.0;
for(int j = ; j <= m; j++)
d[i][j][] = d[i][j - ][] * (1.0 - p[i][j]);
} for(int i = ; i < t; i++)
for(int j = ; j <= m; j++)
for(int k = ; k <= j; k++)
d[i][j][k] += (d[i][j - ][k - ] * p[i][j] + d[i][j - ][k] * (1.0 - p[i][j])); double p1 = 1.0, p2 = 1.0; for(int i = ; i < t; i++) {
s[i][] = d[i][m][];
for(int j = ; j <= m; j++) s[i][j] = s[i][j - ] + d[i][m][j];
} for(int i = ; i < t; i++) p1 *= (s[i][m] - s[i][]);
for(int i = ; i < t; i++) p2 *= (s[i][n - ] - s[i][]);
printf("%.3lf\n", p1 - p2);
}
return ;
}
 

Check the difficulty of problems(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)

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

  3. Check the difficulty of problems(概率+DP)

    http://poj.org/problem?id=2151 看的题解..表示没看懂状态转移方程.. #include<stdio.h> #include<string.h> ...

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

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

  5. POJ2151-Check the difficulty of problems(概率DP)

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

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

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

  7. POJ 2151 Check the difficulty of problems

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

  8. 【POJ】2151:Check the difficulty of problems【概率DP】

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

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

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

随机推荐

  1. C# 模拟鼠标写字

    经常看到别人拿个四四方方的写字板用笔写字,用C#其实也可以实现,大致思路就是处理鼠标的坐标和Graphics, 代码如下: 首先声明两个全局变量 bool isMouseDown = false; P ...

  2. Codeforces Round #261 (Div. 2) B

    链接:http://codeforces.com/contest/459/problem/B B. Pashmak and Flowers time limit per test 1 second m ...

  3. So easy Webservice 4.Java方式访问WebService(使用jdk1.6以上 wsimport命令)

    1.选中要调用的服务单击”服务说明” 2.获取wsdl文件.使用JDK1.6以上的版本的wsimport命令 a) 例如选中:http://webservice.webxml.com.cn/WebSe ...

  4. Using SSH on Linux

    This document covers the SSH client on the Linux Operating System and other OSes that use OpenSSH. W ...

  5. ubuntu 下解决安装包依赖问题

    我们用banshee软件安装豆瓣插件来做个示例: 1.首先在Ubuntu Software Center内搜索banshee播放器 因为我之前已经安装好了,可以看到如下界面,你可以在点击该软件看到in ...

  6. Doragon Kuesuto 1.6

    /* * <<D Q>> * * Author xkfx<wyzxk_fx@163.com> * * 游戏规则:利用适当的决策,在13回合内击杀恶龙取得胜利. * ...

  7. Web App时代的缓存机制新思路

    Web App常见架构 以WebQQ例,WebQQ这个站点的所有内容都是一个页面里面呈现的,我们看到的类似windows操作系统的框架,是它的顶级容器和框架,由AlloyOS的内核负责统筹和管理,然后 ...

  8. 无限极分类,传递一个子ID得到所有父集,用于在前台分层显示标题

    方法: static public function getParents($data,$id){ $arr=array(); foreach ($data as $v) { if ($v['id'] ...

  9. (八)C语言结构体和指针

    指针也可以指向一个结构体变量.定义的一般形式为: struct 结构体名 *变量名; 前面已经定义了一个结构体 stu: struct stu { char *name; int num; char ...

  10. 【Todo】Python面试题分析记录(修饰器等)

    首先,看这一段代码: class A(object): x = 1 gen = (lambda t: (t for _ in xrange(10)))(x) if __name__ == '__mai ...