题意

某场比赛有M道问题,T支队伍,和数字N给出每支队伍解决每道问题的概率。 问这场比赛满足下面两个条件的概率

1.每支队伍至少做出一道题

2.冠军队至少做出N道题。

分析

条件2是不是可以转化为 至少有一支队做出N道及以上道题。

这个题主要是概率,其次才是dp,而且好像不算概率DP。

我们来倒推一下。

设p2为每支队伍做出来的题数都在(1-N-1)的概率。p1为每只队伍至少做出来一道题的概率。那么答案就是p1-p2。

然后我们再来想怎么求p1和p2。设s[i][j]为第i支队伍做出来题数小于等于j的概率。那么

p1=(1-s[1][0])*(1-s[2][0])*...*(1-s[T][0]).

p2=(s[1][N-1]-s[1][0])*(s[2][N-1]-s[2][0])*...*(s[T][N-1]-s[T][0])。

然后再往前推。s[i][j]该怎么求?

我们发现队伍与队伍之间没有关系,于是我们可以每支队伍都通过dp求解。对于每支队伍k

我们令f[i][j]为前i个问题中做出来j个题的概率 f[i][j]=f[i-1][j]*(1-P[k][j])+f[i-1][j-1]*P[k][j];

然后 s[k][j]=sum(f[M][l])(0<=l<=j)

就是这个样子。

这个题的DP是最基础的,但是概率那里我觉得不是特别好想。。(可能因为我菜吧···)

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std;
const int maxn=+;
const int maxm=;
int M,T,N;
double P[maxn][maxm];
double f[maxm][maxm],s[maxn][maxm];
int main(){
while(scanf("%d%d%d",&M,&T,&N)!=EOF&&(M||T||N)){
memset(P,,sizeof(P));
for(int i=;i<=T;i++){
for(int j=;j<=M;j++){
scanf("%lf",&P[i][j]);
}
memset(f,,sizeof(f));
f[][]=1.0;
for(int j=;j<=M;j++){
for(int k=;k<=j;k++){
if(k==)
f[j][k]=f[j-][k]*(-P[i][j]);
else
f[j][k]=f[j-][k-]*P[i][j]+f[j-][k]*(-P[i][j]);
}
}
double sum=;
for(int j=;j<=M;j++){
sum+=f[M][j];
s[i][j]=sum;
}
}
double p1,p2;
p1=p2=1.0;
for(int i=;i<=T;i++){
p1*=(-s[i][]);
}
for(int i=;i<=T;i++){
p2*=(s[i][N-]-s[i][]);
}
double ans=p1-p2;
printf("%.3f\n",ans);
}
return ;
}

【POJ2151】Check the difficulty of problems的更多相关文章

  1. 【poj2151】 Check the difficulty of problems

    http://poj.org/problem?id=2151 (题目链接) 题意 T支队伍,一共M道题,第i支队伍解出第j道题的概率为p[i][j].问每支队伍至少解出1道题并且解题最多的的队伍至少解 ...

  2. 【POJ】【2151】Check the difficulty of problems

    概率DP kuangbin总结中的第8题 一开始题目看错导致想转移方程想错了……想成f[i][j]表示前 i 个队伍中最多的做出来 j 道题的概率……sigh 看了下题解……其实是对于每个队伍 i 单 ...

  3. 【POJ】2151:Check the difficulty of problems【概率DP】

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8903   ...

  4. POJ 2151 Check the difficulty of problems

    以前做过的题目了....补集+DP        Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K ...

  5. Check the difficulty of problems

    Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5830 Acc ...

  6. Check the difficulty of problems(POJ 2151)

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5457   ...

  7. POJ 2151 Check the difficulty of problems (动态规划-可能DP)

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4522   ...

  8. POJ 2151 Check the difficulty of problems 概率dp+01背包

    题目链接: http://poj.org/problem?id=2151 Check the difficulty of problems Time Limit: 2000MSMemory Limit ...

  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. C# 导出图片到Word (通过XML实现)

    private void ExportDataToWord(string content) { StringBuilder sbMain = new StringBuilder(); #region ...

  2. openresty && hashids&& redis 生成短链接

    1. 原理     a. 从redis 获取需要表示的短链接的id( redis incr)     b. hashids 编码 id     c. openresty  conteent_by_lu ...

  3. UVA12716 GCD XOR 数论数学构造

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u010682557/article/details/36204645 题目给你一个N,让你求 两个数 ...

  4. Redis简单介绍与安装

    Redis是一个开源,高级的键值存储和一个适用的解决方案,用于构建高性能,可扩展的Web应用程序. Redis有三个主要特点,使它优越于其它键值数据存储系统 - 1) Redis将其数据库完全保存在内 ...

  5. 6.Python使用Pandas小案例

    1.使用以下命令引入Pandas和xlrd,引入成功后在pycharm的setting导入即可使用(pip3是由于个人python版本为3.6)==在dos命令行输入以下信息 pip3 install ...

  6. RK3288 查看ddr频率

    转载请注明出处:https://www.cnblogs.com/lialong1st/p/8515135.html RK3288 查看 ddr 当前频率的方式有两种,第一种是通过 adb 查看,第二种 ...

  7. 谈谈GPU与FPGA的一些看法

    从几个方面来介绍一下GPU和FPGA. 从峰值性能来说,GPU(10Tflops)远远高于FPGA(<1TFlops).GPU上面成千上万个core同时跑在GHz的频率上还是非常壮观的,最新的G ...

  8. i和j的值交换的方法

        方法一: int i = 3, j = 5; int c = i; i = j; j = c;     方法二: int i = 3, j = 5; int n = i + j; i = n ...

  9. [Java][Web]Response学习

    // 在 http 中,meta 标签可以模拟响应头 response.setHeader("Content-type", "text/html;charset=UTF- ...

  10. 初学者手册-IDEA中的Git

    1.Git的更新.提交.还原 IDEA中Git的更新.提交.还原方法 2.设置Git的提交方式为http 3.