poj 2151
| Time Limit: 2000MS | Memory Limit: 65536K | |
| Total Submissions: 4873 | Accepted: 2131 |
Description
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
Output
Sample Input
2 2 2
0.9 0.9
1 0.9
0 0 0
Sample Output
0.972
分析:求保证每个队至少做对一题,冠军队做对n个题的概率。
保证每个队至少做对一题,冠军队做对n个题的概率=每个队至少做对一道题-没有一个队做到n到题。(每个队最多做了n-1个题),
dp[i][j][k]表示第i个对做到j题,目前做对了k题。
dp[i][j[k]=dp[i][j-1][k]*(1-a[i][j])+dp[i][j-1][k-1]*a[i][j];
s[i][k]表示i对至少做对了k题的概率
注意边界。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
double dp[][][];
int main()
{
int m,t,n,i,j,k;
double a[][],cnt,ans,sum,s[][];
while(~scanf("%d%d%d",&m,&t,&n))
{
memset(dp,,sizeof(dp));
memset(s,,sizeof(s));
cnt=;
ans=;
sum=;
if(m==&&t==&&n==)
break;
for(i=;i<=t;i++)
{
for(j=;j<=m;j++)
{
scanf("%lf",&a[i][j]) ;
cnt*=(-a[i][j]);
}
ans*=(-cnt);
cnt=;
}
for(i=;i<=t;i++)
{
dp[i][][]=-a[i][];
dp[i][][]=a[i][];
for(j=;j<=m;j++)
dp[i][j][]=dp[i][j-][]*(-a[i][j]);
for(j=;j<=m;j++)
{
for(k=;k<=j;k++)
{
dp[i][j][k]=dp[i][j-][k]*(-a[i][j])+dp[i][j-][k-]*a[i][j]; }
}
for(k=;k<=n-;k++)
s[i][n-]+=dp[i][m][k];
}
for(i=;i<=t;i++)
{
sum*=s[i][n-]; }
printf("%.3lf\n",ans-sum); }
return ;
}
poj 2151的更多相关文章
- poj 2151 Check the difficulty of problems(概率dp)
poj double 就得交c++,我交G++错了一次 题目:http://poj.org/problem?id=2151 题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 问 ...
- POJ 2151 Check the difficulty of problems 概率dp+01背包
题目链接: http://poj.org/problem?id=2151 Check the difficulty of problems Time Limit: 2000MSMemory Limit ...
- POJ 2151 Check the difficulty of problems:概率dp【至少】
题目链接:http://poj.org/problem?id=2151 题意: 一次ACM比赛,有t支队伍,比赛共m道题. 第i支队伍做出第j道题的概率为p[i][j]. 问你所有队伍都至少做出一道, ...
- POJ 2151 Check the difficulty of problems
以前做过的题目了....补集+DP Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K ...
- Check the difficulty of problems(POJ 2151)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5457 ...
- POJ 2151 Check the difficulty of problems (动态规划-可能DP)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4522 ...
- [ACM] POJ 2151 Check the difficulty of problems (概率+DP)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4748 ...
- POJ 2151 Check the difficulty of problems (概率DP)
题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 ,求每队至少解出一题且冠军队至少解出N道题的概率. 析:概率DP,dp[i][j][k] 表示第 i 个队伍,前 j 个题,解出 ...
- POJ 2151 Check the difficulty of problems (概率dp)
题意:给出m.t.n,接着给出t行m列,表示第i个队伍解决第j题的概率. 现在让你求:每个队伍都至少解出1题,且解出题目最多的队伍至少要解出n道题的概率是多少? 思路:求补集. 即所有队伍都解出题目的 ...
随机推荐
- 为什么要设置Java环境变量(详解)
关于java环境变量配置讲解: 1. PATH环境变量.作用是指定命令搜索路径,在shell下面执行命令时,它会到PATH变量所指定的路径中查找看是否能找到相应的命令程序.我们需要把 jdk安装目录下 ...
- C# 与 C++ 交互
参考: http://www.cnblogs.com/liping13599168/archive/2011/03/31/2000320.html Platform Invoke Tutorial:h ...
- This 在 C# 中的含义
这涉及到c# 中的oo思想,其实不管在c# 或其他编码语言中,很多抽象的概念当你项目经验多了,自然而然就会对这些东西理解的更透彻点,更加具象. 这里有一些面向对象编程的概念需要说明:类(Class)的 ...
- strace跟踪操作的详细内容
- 前端开发构建工具gulp的安装使用
曾几何时还在使用grunt作为前端的构建工具,直到有一天同事向我推荐了gulp,在这里博主将不讨论gulp与grunt各自优势的比较,只为大家介绍gulp如何安装和使用. Gulp 是用 nodejs ...
- IDEA14创建Maven管理的Java Web项目
刚开始进入公司实习,什么都不懂的小白,经过一上午加一点下午的时间,各种百度之后,终于找到了完整的流程,亲测成功,下面是我的一些步骤和图解,如果有什么错误,欢迎指正. 主要分为下面的几个步骤: 1.前期 ...
- ACM YTU 《挑战编程》第一章 入门 Problem E: Graphical Editor
Description Graphical editors such as Photoshop allow us to alter bit-mapped images in the same way ...
- ListView复用和优化详解
我们每一个Android开发人员对ListView的使用肯定是很熟悉的,然而多少人能真正的懂ListView的缓存机制呢,说白了就是ListView为了提高效率,而内部实现的一种优化,牺牲一点内存.而 ...
- 研究在SAE上搭建最新wordpress
安装SAE上的wordpress,创建应用选择wordpress模板,安装后是3.4版本 新建一个版本2,下载最新wordpress安装包并解压到版本2中 初步猜想修改地方: 数据库配置:wp-con ...
- 《JavaScript高级程序设计 第3版》-学习笔记-2
P31-P82页 1.相等不相等与全等不全等 相等不相等:先转换后比较.对于只有一个对象,调用valueOf方法得到基本类型值再按基本类型转换:如果两个都是对象,则比较他们是否是同一个对象(引用或指针 ...