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

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

题意:在acm比赛中,n题,t队。给出每个队做对每题的概率,问每队至少对一题,至少有一队做对至少m题的概率。(本解题报告中的n,m与原题中相反)

分析:dp,f[i][j]表示第i个队伍做对第j题的概率。g[i][j][k]表示第i个队伍对于前j题而言做对k道的概率。

g[i][j][k] = g[i][j - 1][k - 1] * (f[i][j]) + g[i][j - 1][k] * (1 - f[i][j]);

有了所有的g,我们就可以求出每个队至少做对1题的概率:ans *= 1 - g[i][n][0];

再减去每个队都只做对1~m-1题的概率(把每个队做对1~m-1题的概率加和,并把各队结果相乘)

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
double f[][];
double dp[][][];
int main(){
int n,t,m;
while(scanf("%d%d%d",&n,&t,&m)!=EOF){
if(n==&&t==&&m==)
break;
memset(f,,sizeof(f));
memset(dp,,sizeof(dp));
for(int i=;i<t;i++){
for(int j=;j<=n;j++)
scanf("%lf",&f[i][j]);
} for(int i=;i<t;i++){
dp[i][][]=;
for(int j=;j<=n;j++){
dp[i][j][]=dp[i][j-][]*(-f[i][j]);
for(int k=;k<=j;k++)
dp[i][j][k]=dp[i][j-][k-]*f[i][j]+dp[i][j-][k]*(-f[i][j]);
}
} double ans=;
for(int i=;i<t;i++)
ans*=(-dp[i][n][]); double temp=;
for(int i=;i<t;i++){
double sum=;
for(int j=;j<m;j++)
sum+=dp[i][n][j];
temp*=sum;
} printf("%.3lf\n",ans-temp); }
return ;
}
												

poj 2151 概率DP(水)的更多相关文章

  1. POJ 2151 概率DP

    主要的子问题是每一个队伍有一个做出题目的概率,求做出k个题目的概率.简单的简单的组合数DP.想清楚即可. 1: #include <iostream> 2: #include <cs ...

  2. Check the difficulty of problems - poj 2151 (概率+DP)

    有 T(1<T<=1000) 支队伍和 M(0<M<=30) 个题目,已知每支队伍 i 解决每道题目 j 的的概率 p[i][j],现在问:每支队伍至少解决一道题,且解题最多的 ...

  3. Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题

    除非特别忙,我接下来会尽可能翻译我做的每道CF题的题面! Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题 题面 胡小兔和司公子都认为对方是垃圾. 为了决出谁才是垃 ...

  4. 13年山东省赛 The number of steps(概率dp水题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud The number of steps Time Limit: 1 Sec  Me ...

  5. poj 3071 Football (概率DP水题)

    G - Football Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit ...

  6. POJ 2096 (概率DP)

    题目链接: http://poj.org/problem?id=2096 题目大意:n种bug,s个子系统.每天随机找一个bug,种类随机,来自系统随机.问找齐n种bug,且每个子系统至少有一个bug ...

  7. POJ 3701 概率DP

    给定2^n 支足球队进行比赛,n<=7. 队伍两两之间有一个获胜的概率,求每一个队伍赢得最后比赛的概率是多少? 状态其实都是很显然的,一开始觉得这个问题很难啊,不会.dp[i][j] 表示第i支 ...

  8. Scout YYF I POJ - 3744(概率dp + 矩阵快速幂)

    题意: 一条路上有n个地雷,你从1开始走,单位时间内有p的概率走一步,1-p的概率走两步,问安全通过这条路的概率 解析: 很容易想到 dp[i] = p * dp[i-1] + (1 - p) * d ...

  9. poj 3071 概率dp

    转自:cxlove 题目:有2^n个队,相邻的两两打淘汰赛,,求最后哪个队夺冠的概率最大 dp[i][j]表示第i轮的时候,第j去支队伍赢的概率. 那么dp[i][j]的前提就是i-1轮的时候,j是赢 ...

随机推荐

  1. apache单ip配置多端口多站点

    1.修改 /etc/httpd/conf/httpd.conf 添加一个Listen,如: Listen 80 Listen 8001 Listen 8002 2.添加一个VirtualHost #v ...

  2. Python2.x 和 3.x 的区别

    Python有两个版本,2.x 和 3.x ,两个版本不兼容,3.x 不不考虑对2.x代码的向后兼容. 在3.x中,一些语法,内建函数和对象的行为都有所调整. 大部分的python库都支持 pytho ...

  3. 通过eclipse启动tomcat设置JAVA_OPTS失败的解决方案

    clipse中配置tomcat方法: Window-->Preference-->Server-->Runtime Environment-->add-->Apache ...

  4. 微信端H5页面问题总结

    1.div元素不确定高度的情况下背景图片显示问题,解决后可以自适应不同分辨率的屏幕大小,div元素的background-size设置100%后,其自身的高度和宽度不能再设置. .register-t ...

  5. django中的auth模块以及分页器

    1.auth模块 auth模块是Django提供的标准权限管理系统,可以提供用户身份认证,和权限管理 auth可以和admin模块配合使用, 快速建立网站的管理系统 在INSTALLED_APPS中添 ...

  6. iRate快速绕坑使用

    目的 iRate库通过激励用户去AppStore打分,来帮助你提升iPhone和Mac App的质量.这是取得经常使用的目标用户的意见的最好的方式之一. 方案(小弟想说的重点) 以前,App中都是显示 ...

  7. Python线程间事件通知

    Python事件机制 事件机制:这是线程间最简单的通信机制:一个线程发送事件,其他线程等待事件事件机制使用一个内部的标志,使用set方法进行使能为True,使用clear清除为falsewait方法将 ...

  8. centos7部署harbor

    官网 https://github.com/goharbor/harbor 1.升级系统内核 rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrep ...

  9. oracle中序列,同义词的创建

    序列 序列是用来生成唯一,连续的整数的数据库对象.序列通常用来自动生成主机那或唯一键的值.序列可以按升序排序, 也可以按降序排序.例如,销售流水表中的流水号可以使用序列自动生成. 创建序列语法: cr ...

  10. java 微信开发 常用工具类(xml传输和解析 json转换对象)

    与微信通信常用工具(xml传输和解析) package com.lownsun.wechatOauth.utl; import java.io.IOException; import java.io. ...