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道题的概率是多少? 思路:求补集. 即所有队伍都解出题目的 ...
随机推荐
- 自己做的demo--左连接
下面四张表是数据库中已经有的数据: 第一步: 1.left join左连接,left outer join 左外连接,只是写法不同,相同的概念. 2.左连接查出来的结果是一定包含left关键字左边的表 ...
- 如何写robots.txt?
robin 发表在 八月 2, 2006 在国内,网站管理者似乎对robots.txt并没有引起多大重视,应一些朋友之请求,今天想通过这篇文章来简单谈一下robots.txt的写作. robots.t ...
- RABBITMQ安装注意点
关于 RABBITMQ的配置问题安装问题windows7 和window 10我都试了windows10安装和配置不要出现中文和空格,不然你日寒飞的心都有了ERLANG的安装也是Win7直接默认的路径 ...
- PHP 单一入口
单一入口概述 单一入口的应用程序就是说用一个文件处理所有的HTTP请求,例如不管是列表页还是文章页,都是从浏览器访问index.php文件,这个文件就是这个应用程序的单一入口. 打个比方,大家都要上W ...
- 网页解析Jsoup简单使用
public static void main(String[] args) throws IOException { //System.out.println("Hello World!& ...
- SQL70001: This statement is not recognized in this context.
关于错误: SQL70001: This statement is not recognized in this context. 的产生原因以及解决办法. 在SQL Server Databas ...
- jquery 之选择符
css:选择符$('#selected-plays > li') 使用了子元素组合符,查找 ID 为 selected-plays 的元素的子元素( > )中所有的列表 li$('#sel ...
- 修改Tomcat命令窗口的名字
在运行多个tomcat窗口的时候,可以通过修改tomcat命令窗口的名字来区分不同的tomcat,修改如下: 找到tomcat下面的这个文件:tomcat_home\bin\catalina.bat, ...
- php 常用
零:重要的PHP超级全局变量 1.$_SERVER $_SERVER超级全局变量包含由web服务器创建的信息,它提供了服务器和客户配置及当前请求环境的有关信息.根据服务器不同,$_SERVER中的变量 ...
- 存储过程修改产品描述页图片alt描述信息
今天修改了所有产品的图片信息,用到了存储过程.在参考下面存储过程以后,终于搞定了. 1 BEGIN 2 DECLARE Done INT DEFAULT 0; 3 4 DECLARE CurrentL ...