poj 2151 Check the difficulty of problems (DP)
来源:互联网 发布:网络信用查询 编辑:程序博客网 时间:2024/06/05 06:04
点击打开链接
在acm比赛中,n题,t队。给出每个队做对每题的概率,问每队至少对一题,至少有一队做对至少m题的概率
dp,f[i][j]表示第i个队伍做对第j题的概率。g[i][j][k]表示第i个队伍对于前j题而言做对k道的概率。
g[i][j][k] = g[i][j - 1][k - 1] * (f[i][j]) + g[i][j - 1][k] * (1 - f[i][j]);
有了所有的g,我们就可以求出每个队至少做对1题的概率:ans *= 1 - g[i][n][0];
再减去每个队都只做对1~m-1题的概率(把每个队做对1~m-1题的概率加和,并把各队结果相乘)
#include"stdio.h"#include"string.h"double map[1001][31],dp[1001][31][31];int main(){int i,j,k,n,m,t;double ans,sum,temp;while(scanf("%d%d%d",&n,&t,&m)!=-1){if(n==0&&m==0&&t==0)break;for(i=0;i<t;i++){for(j=1;j<=n;j++)scanf("%lf",&map[i][j]);}memset(dp,0,sizeof(dp));for(i=0;i<t;i++){dp[i][0][0]=1;for(j=1;j<=n;j++){dp[i][j][0]=dp[i][j-1][0]*(1-map[i][j]);for(k=1;k<=j;k++)dp[i][j][k]=dp[i][j-1][k]*(1-map[i][j])+dp[i][j-1][k-1]*map[i][j];}}ans=1;for(i=0;i<t;i++)ans*=1-dp[i][n][0];temp=1;for(i=0;i<t;i++){sum=0;for(j=1;j<m;j++){sum+=dp[i][n][j];}temp*=sum;}ans-=temp;printf("%.3f\n",ans);}return 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)
- 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)
- 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上查看mysql数据库启动信息的命令
- sap crm 销售订单创建之后显示文档正在分发
- 【计算几何】 poj2318 TOYS
- 《Effective STL》条款24:当关乎效率时应该在map::operator[]和map::insert之间仔细选择
- apache+tomcat 集群
- poj 2151 Check the difficulty of problems (DP)
- Eclipse断点调试
- C++Simplify04-标准库string和vector
- Struts2.3.4 GA版配置流程
- Linux查看进程 杀进程
- 设置SAP migo、mb1b、mb1c中的字段
- HDU2647(逆向拓扑排序)
- ArcGIS version not specified.
- POJ 3624 Charm Bracelet (0-1背包)