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. 浏览器被hao.360.cn劫持怎么办

    特么的现在互联网太没节操了,一大早发现我的浏览器被hao.360.cn劫持了,弄了好久都没弄好,后来一想可能是因为qvod的原因,这可是哥当年看片的神器啊…… 废话不说: 1,进入:C:\Progra ...

  2. SQL语句like子句中的转义符

    如果想在SQL LIKE里查询有下划线'_'或是'%'等值的记录,直接写成like 'XXX_XX',则会把'_'当成是like的通配符.SQL里提供了 escape子句来处理这种情况,escape可 ...

  3. CUBRID学习笔记 44 UPDATE 触发器 更新多表 教程

    cubrid的中sql查询语法UPDATE c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com ...

  4. 关于dom ready事件

    0.加载完页面,解析完所有标签(不包括执行CSS和JS),并如规范中所说的设置 interactive 和执行每个静态的script标签中的JS,然后触发. 1.没有js,有css,有img,DOMC ...

  5. JSON的操作

    今天遇到了一个要解析JSON的需求.在http://stackoverflow.com/questions/1826727/how-do-i-parse-json-with-ruby-on-rails ...

  6. ThreadLocal 实现线程内共享变量

    package com.cn.gbx; import java.util.Date; import java.util.Random; import java.util.Timer; import j ...

  7. iOS - UIScrollView

    前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIScrollView : UIView <NSCoding> @available(iOS 2.0, ...

  8. HDU4801·二阶魔方

    题意:给定二阶魔方初始状态,问N(1 <= N <= 7)步旋转操作以内最多能使几个面相同. dfs搜索+剪枝. 魔方的每个旋转操作即对应于一个置换操作.又因为相对运动,上层左旋一次和下层 ...

  9. (三)ubuntu学习前传—uboot常见环境变量

    1.环境变量如何参与程序运行(1)环境变量有2份,一份在Flash中,另一份在DDR中.uboot开机时一次性从Flash中读取全部环境变量到DDR中作为环境变量的初始化值,然后使用过程中都是用DDR ...

  10. jquery mobile 学习总结

    <!doctype html><html lang="zh-CN"><head> <meta charset="UTF-8&qu ...