题意

某场比赛有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. 洛谷【P4551】最长异或路径

    浅谈\(Trie\):https://www.cnblogs.com/AKMer/p/10444829.html 题目传送门:https://www.luogu.org/problemnew/show ...

  2. happynear_caffe编译时,缺少头文件caffe.pb.h的问题

    由于一些问题,需要编译caffe 的windows版本,用的是happynear的caffe版本,在caffe.pb.h遇到了问题 如何生成 caffe.pb.h 将protobuf 里的 proto ...

  3. jeecg中树形显示的用法

    1.GoodsController中显示的方法如下: @RequestMapping(params = "goodsgrid") @ResponseBody public Obje ...

  4. linux下使用tar命令详解

    解压语法:tar [主选项+辅选项] 文件或者目录 使用该命令时,主选项是必须要有的,它告诉tar要做什么事情,辅选项是辅助使用的,可以选用. 主选项: c 创建新的档案文件.如果用户想备份一个目录或 ...

  5. POJ2739(尺取法)

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23931 ...

  6. Thread之六:线程创建方法

    1.继承Thread类,重写该类的run()方法. 2.实现Runnable接口,并重写该接口的run()方法,该run()方法同样是线程执行体,创建Runnable实现类的实例,并以此实例作为Thr ...

  7. hadoop从调整GC到关键Counter计算原理分析

     hadoop集群中发现使用Parallel Scavenge+Parallel Old收集器组合进行垃圾收集(这也是server端jvm默认的GC方式)时CPU占用可能会非常高,偶尔会出现爆满的状态 ...

  8. 【POJ】2385 Apple Catching(dp)

    Apple Catching Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13447   Accepted: 6549 D ...

  9. 【洛谷】P2880 [USACO07JAN]平衡的阵容Balanced Lineup(st表)

    题目背景 题目描述: 每天,农夫 John 的N(1 <= N <= 50,000)头牛总是按同一序列排队. 有一天, John 决定让一些牛们玩一场飞盘比赛. 他准备找一群在对列中为置连 ...

  10. Memory leak by misusing Autofac

    Recently I’ve found out that we can easily cause a memory leaks in our .net application by improper ...