POJ 2151 Check the difficulty of problems(概率问题)
来源:互联网 发布:域名注册是什么 编辑:程序博客网 时间:2024/05/23 20:06
转载请注明出处,谢谢http://blog.csdn.net/acm_cxlove/article/details/7854526 by---cxlove
题目:出题方需要满足一些规则,尽可能保证每个队都能做出一题,保证第一名至少做出m道题。
现在给出T个队,N道题,并且给出每一个队解出每一题的概率,求这套题能满足规则的概率为多大
http://poj.org/problem?id=2151
被 阳阳拉着来做概率。。。
首先可以求出每个队至少解出一题的概率,然后在这基础上要求至少有一个队解出m题的概率
后者可能不太好求,可以考虑
每个队至少解出一题的概率-所有队解出题的数量i (m>i>=1)
后者可以用DP解决,dp[i][j]表示前i道题,做出j道的概率
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>#define eps 1e-10#define N 100005#define inf 1<<20#define zero(a) (fabs(a)<eps)#define lson (step<<1)#define rson (step<<1|1)using namespace std;int n,t,m;double a[1005][30];double dp[35][35];int main(){ while(scanf("%d%d%d",&n,&t,&m)!=EOF&&n+t+m){ double sum=1; for(int i=1;i<=t;i++){ double tmp=1; for(int j=1;j<=n;j++){ scanf("%lf",&a[i][j]); tmp*=1-a[i][j]; } sum*=1-tmp; } double temp=1; for(int i=1;i<=t;i++){ memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int j=1;j<=n;j++){ for(int k=0;k<j;k++){ dp[j][k+1]+=dp[j-1][k]*a[i][j]; dp[j][k]+=dp[j-1][k]*(1-a[i][j]); } } double tmp=0; for(int j=1;j<m;j++) tmp+=dp[n][j]; temp*=tmp; } printf("%.3f\n",sum-temp); } return 0;}
- POJ 2151 Check the difficulty of problems(概率问题)
- POJ 2151 Check the difficulty of problems 概率DP
- poj 2151 Check the difficulty of problems 概率dp
- Poj 2151 Check the difficulty of problems (概率)
- POj 2151 Check the difficulty of problems 概率DP
- POJ 2151 Check the difficulty of problems(概率DP)
- 概率dp POJ 2151 Check the difficulty of problems
- poj 2151 Check the difficulty of problems(概率dp)
- poj 2151 Check the difficulty of problems(概率dp)
- POJ 2151 Check the difficulty of problems(概率dp)
- poj 2151 Check the difficulty of problems 概率dp
- poj 2151 Check the difficulty of problems(概率DP)
- poj 2151 Check the difficulty of problems(概率dp)
- poj 2151 Check the difficulty of problems 概率dp
- poj 2151 Check the difficulty of problems (概率dp)
- POJ 2151 Check the difficulty of problems (概率dp)
- poj 2151 Check the difficulty of problems (概率DP)
- poj 2151 Check the difficulty of problems (dp,概率)
- linux中线程同步和互斥的区别
- 项目名前有个红色感叹号的解决办法
- 【Android】The Manifest File清单文件
- poj 1154 LETTERS
- Android 利用Java实现压缩与解压缩(zip、gzip)支持中文路径
- POJ 2151 Check the difficulty of problems(概率问题)
- hdu(4005)floyd
- Re-installation failed due to different application signatures.
- 求解答:Android的一个小的应用程序在模拟器中的运行问题
- Magento更强大的编辑器Fontis_Wysiwyg
- JAVA继承父类的同名成员方法的访问权限
- Oracle定时任务
- 基础备忘:关于构造函数、拷贝构造函数、析构函数
- Linux下Tomcat的启动、关闭、杀死进程