poj 2151 Check the difficulty of problems (概率dp)
来源:互联网 发布:平板蓝牙软件下载 编辑:程序博客网 时间:2024/05/22 03:27
/*一次比赛中,共M道题,T个队,p[i][j]表示队i解出题j的概率;问每队至少解出一题且冠军队至少解出N道题的概率。dp[i][j][k]表示第i支队伍在前j道题中解出k道的概率问题的解可以转化为:每队均至少做一题的概率(用P1表示)减去每队做题数均在1到N-1之间的概率(用P2表示)。*/# include <stdio.h># include <algorithm># include <string.h># include <iostream>using namespace std;double dp[1010][35][35];double p[1010][35];int main(){ int i,j,k,n,t,m; while(~scanf("%d%d%d",&m,&t,&n),m+t+n) { for(i=1; i<=t; i++) { for(j=1; j<=m; j++) scanf("%lf",&p[i][j]); } memset(dp,0,sizeof(dp)); for(i=1; i<=t; i++) { dp[i][0][0]=1; for(j=1; j<=m; j++) { dp[i][j][0]=dp[i][j-1][0]*(1-p[i][j]); for(k=1; k<=m; k++) { dp[i][j][k]=dp[i][j-1][k-1]*p[i][j]+dp[i][j-1][k]*(1-p[i][j]); } } } double p1=1,p2=1; for(i=1;i<=t;i++)///每队至少做一题的概率 p1*=1-dp[i][m][0]; double sum=0; for(i=1;i<=t;i++)///每队做题数均在1到N-1之间的概率 { sum=0; for(j=1;j<=n-1;j++)///单独一支队伍,同支队伍是用+ sum+=dp[i][m][j]; p2*=sum; } printf("%.3lf\n",p1-p2); } return 0;}
0 0
- 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)
- 概率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,概率)
- Check the difficulty of problems - POJ 2151 概率dp
- POJ 2151 Check the difficulty of problems 概率dp
- 【综述】(MIT博士)林达华老师-"概率模型与计算机视觉”
- 赛珍珠大地读书小感
- 百度快照更新与排名的关系
- Python For Data Analysis笔记
- JAVA wait(), notify(),sleep详解
- poj 2151 Check the difficulty of problems (概率dp)
- 自己动手写shell命令之who
- 修改title标题对于老站的影响
- 说说静态URL与动态URL
- 括号配对问题
- 浅谈百度比较讨厌的作弊方式
- 万事开头难 新站优化要用心
- zoj 3822 Domination
- Mysql 不同版本 说明