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. 使用C#的新特性:可空类型

    随着C#语言最新标准的出炉,现在它也提供了对可空类型的支持.这个小变化将会在处理那些包括可选项的数据库记录时非常有用.当然在其他地方,它也是非常有用的. 简单说来,可空数据类型就是包含了所定义的数据类 ...

  2. 2、SpringBoot+Mybatis整合------一对一

    开发工具:STS 代码下载链接:https://github.com/theIndoorTrain/SpringBoot_Mybatis01/tree/93398da60c647573645917b2 ...

  3. mycat特点及用途

    Mycat关键特性 关键特性 支持SQL92标准 遵守Mysql原生协议,跨语言,跨平台,跨数据库的通用中间件代理. 基于心跳的自动故障切换,支持读写分离,支持MySQL主从,以及galera clu ...

  4. BZOJ3170: [Tjoi2013]松鼠聚会(切比雪夫距离转曼哈顿距离)

    Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1524  Solved: 803[Submit][Status][Discuss] Descripti ...

  5. node服务端渲染(完整demo)

    简介 nodejs搭建多页面服务端渲染 技术点 koa 搭建服务 koa-router 创建页面路由 nunjucks 模板引擎组合html webpack打包多页面 node端异步请求 服务端日志打 ...

  6. MAC中向阿里云服务器上传文件

    打开mac中的终端 使用命令:$scp /local/file user@remote:/file /local/file 是本地文件 后面部分[用户名]@[ip地址:][服务器中的文件目录] not ...

  7. thinkphp3.2 where 条件查询 复查的查询语句

    复查的查询语句 有的时候,我们希望通过一次的查询就能解决问题,这个时候查询条件往往比较复杂,但是却比多次查询库来的高效. 实在是搞不定的话就直接用$where[‘_string’] = ‘xxxx’, ...

  8. C语言字符篇(四)字符串查找函数

      #include <string.h>   char *strchr(const char *s, int c);   The strchr() function returns a ...

  9. HDU3853 概率DP

    LOOPS   Homura wants to help her friend Madoka save the world. But because of the plot of the Boss I ...

  10. 2018Ec-Final比赛总结

    一场匆忙的旅程. NCC_9754_ Victory的最后一场比赛终究没能victory. 去的时候晕车到吐了两次,到宾馆吃完饭直接睡了,但还是两天都昏昏沉沉的头疼的厉害,第二天直接步行去了西工大体育 ...