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. [Effective Java]第四章 类和接口

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  2. CUBRID学习笔记 38 net调用java的函数过程

    首先要设置java_stored_procedure 为yes  该配置项在cubrid.conf中 书写并编译java代码 public class SpCubrid{      public st ...

  3. Sbt的使用初步和用sbt插件生成eclipse工程

    以前一直是用maven去管理java项目,现在开始写scala项目了但是在scala-ide中去编译scala项目和sbt的区别一直没弄清楚受到文章:http://my.oschina.net/yjw ...

  4. iOS案例:读取指定目录下的文件列表

    // // main.m // 读取指定目录下的文件列表 // // Created by Apple on 15/11/24. // Copyright © 2015年 Apple. All rig ...

  5. 是时候改变你的开发方式了-XAF信息系统快速框架介绍

    我是一名.Net开发者,从DOS时代Turbo c 算起(1996年),马上满20年了.想想写过的代码真是不少,却做了很多重复反复的编码工作.当然中间也带过团队做过几个大项目,但是代码仍没写够,还是每 ...

  6. Memcached通用类(基于Memcached Client Library)

    分享下自己编写的Memcached通用类.欢迎大家帮忙指点下哈~ 使用的是.NET memcached client library 客户端+Memcached Providers using Sys ...

  7. 百度编辑器Ueditor的简单调用

    先去ueditou.baidu.com网站下载百度编辑器,放到项目根目录下的Data目录中,然后引入文件 <!DOCTYPE html> <html lang="en&qu ...

  8. 三种实例化bean的方式

    在spring中有三中实例化bean的方式: 一.使用构造器实例化:(90%通常使用的一个方法) 二.使用静态工厂方法实例化: 三.使用实例化工厂方法实例化. 每种实例化所采用的配置是不一样的: 一. ...

  9. css + html 小知识总结

    Html+CSS基础之Html 注:本文摘自慕课网http://www.imooc.com   HTML+CSS基础课程: 1. HTML是网页内容的载体.内容就是网页制作者放在页面上想要让用户浏览的 ...

  10. C++——类继承

    类库:类库由类声明和实现构成.类组合了数据表示和类方法,因此提供了比函数库更加完整的程序包. 类继承:从已有的类派生出新的类,派生类继承了原有类(称为基类)的特征,包括方法. 通过类继承可以完成的工作 ...