题意:给出m、t、n,接着给出t行m列,表示第i个队伍解决第j题的概率。
现在让你求:每个队伍都至少解出1题,且解出题目最多的队伍至少要解出n道题的概率是多少?

思路:求补集。
即所有队伍都解出题目的概率,减去所有队伍解出的题数在1~n-1之间的概率

这里关键是如何求出某个队伍解出的题数在1~n-1之间的概率,采用dp的方法:

用p(i,j)表示前i道题能解出j道的概率,有
p(i,j)=p(i-1,j)*(1-p(i))+p(i-1,j-1)*p(i)
p(i)表示解出第i题的概率。

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio> using namespace std;
const int maxT=+;
const int maxm=;
int m,t,n;
double prob[maxm]; //存储队伍解决第i道题的概率
double p[maxm][maxm]; //p[i][j]表示某队伍前i道题解决了j道题的概率
double pb[maxT]; //pb[i]存储第i个队伍解出的题数在1~n-1之间的概率
double ret; //所有队伍都解出题的概率 int main() {
while(scanf("%d%d%d",&m,&t,&n)!=EOF) {
if(m== && t== && n==)
break;
ret=;
for(int i=; i<t; i++) {
p[][]=;
for(int j=; j<=m; j++) {
scanf("%lf",&prob[j]);
p[j][]=p[j-][]*(-prob[j]);
p[j][j]=p[j-][j-]*prob[j];
}
for(int k=; k<=m; k++) {
for(int r=; r<k; r++) {
p[k][r]=p[k-][r-]*(prob[k])+p[k-][r]*(-prob[k]);
}
}
pb[i]=;
for(int j=; j<=n-; j++) {
pb[i]+=p[m][j];
}
ret*=(-p[m][]);
}
double sum=; //求所有队伍解出的题数在1~n-1之间的概率
for(int i=; i<t; i++) {
sum*=pb[i];
}
double ans=ret-sum;
printf("%.3lf\n",ans); }
return ;
}

POJ 2151 Check the difficulty of problems (概率dp)的更多相关文章

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

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

  2. [ACM] POJ 2151 Check the difficulty of problems (概率+DP)

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

  3. POJ 2151 Check the difficulty of problems (概率DP)

    题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 ,求每队至少解出一题且冠军队至少解出N道题的概率. 析:概率DP,dp[i][j][k] 表示第 i 个队伍,前 j 个题,解出 ...

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

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

  5. POJ 2151 Check the difficulty of problems

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

  6. poj 2151 Check the difficulty of problems(概率dp)

    poj double 就得交c++,我交G++错了一次 题目:http://poj.org/problem?id=2151 题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 问 ...

  7. POJ 2151 Check the difficulty of problems:概率dp【至少】

    题目链接:http://poj.org/problem?id=2151 题意: 一次ACM比赛,有t支队伍,比赛共m道题. 第i支队伍做出第j道题的概率为p[i][j]. 问你所有队伍都至少做出一道, ...

  8. [POJ2151]Check the difficulty of problems (概率dp)

    题目链接:http://poj.org/problem?id=2151 题目大意:有M个题目,T支队伍,第i个队伍做出第j个题目的概率为Pij,问每个队伍都至少做出1个题并且至少有一个队伍做出N题的概 ...

  9. POJ2157 Check the difficulty of problems 概率DP

    http://poj.org/problem?id=2151   题意 :t个队伍m道题,i队写对j题的概率为pij.冠军是解题数超过n的解题数最多的队伍之一,求满足有冠军且其他队伍解题数都大于等于1 ...

随机推荐

  1. Linux基础 30分钟GDB调试快速突破

    引言 Linus心灵鸡汤 在*nix开发中有道卡叫gdb调试,不管你怎么搞. 它依然在那丝毫不会松动.今天致敬一个 活着的传奇 Linus Torvalds Unix 始于上个世纪60年代,在70年代 ...

  2. MIFARE系列8《D8M1.exe》

    软件名:D8M1.exe 更新时间:2014.06.28 操作系统:windowAll 外部设备:D8读卡器 D8M1可以对MIFARE块读写操作,支持1K,4K.检验KEY后返回SAK,QTAQ,U ...

  3. ORA-08189

    OS: [root@yoon ~]# more /etc/oracle-releaseOracle Linux Server release 5.7 DB: Oracle Database 11g E ...

  4. ios中怎么样判断路径最后的后缀名称

    使用hasSuffix属性即可 例如 [photo.thumbnail_pic.lowercaseString hasSuffix:@"gif"]

  5. MongoDB的交互(mongodb/node-mongodb-native)、MongoDB入门

    MongoDB 开源,高性能的NoSQL数据库:支持索引.集群.复制和故障转移.各种语言的驱动程序:高伸缩性: NoSQL毕竟还处于发展阶段,也有说它的各种问题的:http://coolshell.c ...

  6. Swift弹窗

    在一个ViewController中使用以下代码: let alertController = UIAlertController(title: "Game Set", messa ...

  7. OC中实例变量可见度、setter、getter方法和自定义初始化方法

    在对类和对象有一定了解之后,我们进一步探讨实例变量的可见度等相关知识 实例变量的可见度分为三种情况:public(共有),protected(受保护的,默认),private(私有的),具体的不同和特 ...

  8. C#语法功能结构

    1.File打开指定文件夹或者文件,"\"为转义字符System.Diagnostics.Process.Start(Application.StartupPath + " ...

  9. < java.util >-- List接口

    List本身是Collection接口的子接口,具备了Collection的所有方法.现在学习List体系特有的共性方法,查阅方法发现List的特有方法都有索引,这是该集合最大的特点. List:有序 ...

  10. unity工具IGamesTools之批量生成帧动画

    unity工具IGamesTools批量生成帧动画,可批量的将指定文件夹下的帧动画图片自动生成对应的资源文件(Animation,AnimationController,Prefabs) unity工 ...