poj 2151 Check the difficulty of problems- DP
来源:互联网 发布:软件设计师官网 编辑:程序博客网 时间:2024/06/14 01:01
点击打开题目链接http://poj.org/problem?id=2151
#include<cstdio>#include<cstring>#include<algorithm>using namespace std; double dp[1010][35][35]; double s[1010][35];double p[1010][35];// 思路: 求其余队伍至少做一道,冠军队做完所有题//第i支队伍至少做一道题的概率 — 第i支队伍做1-n-1 道题的概率// 第i支队伍做 k道题的概率 //第i支队伍在前n道题中做k道的概率 //入手点:第i支队伍在前0道题中做0道的概率为1 int main(){int i,j,k;int m,t,n;double p1,p2;while(~scanf("%d%d%d",&m,&t,&n)){if(!m && !t &&!n)break;memset(dp,0,sizeof(dp));memset(s,0,sizeof(s));for(i=1;i<=t;i++){for(j=1;j<=m;j++){scanf("%lf",&p[i][j]);}}for(i=1;i<=t;i++){dp[i][0][0]=1;//第i支队伍在前0道题中做出0道的概率为1 for(j=1;j<=m;j++) //求出所有队伍都做0道题的概率 {dp[i][j][0]=dp[i][j-1][0]*(1.0-p[i][j]);}}for(i=1;i<=t;i++){for(j=1;j<=m;j++){for(k=1;k<=j;k++){//第i支队伍在前j道题中做k道=第i支队伍在前j-1道中做k-1道,在第j道中作出一道//&& 第i支队伍在前j-1 道题中做k道 ,第j道没有做出 dp[i][j][k]=dp[i][j-1][k-1]*p[i][j]+dp[i][j-1][k]*(1-p[i][j]);}}s[i][0]=dp[i][m][0];//第i队作出0道 for(k=1;k<=m;k++){s[i][k]=s[i][k-1]+dp[i][m][k];}}p1=p2=1.0;for(i=1;i<=t;i++){p1*=(s[i][m]-s[i][0]);//第i队至少作出一道题的概率 p2*=(s[i][n-1]-s[i][0]);//第i队做题数在 1—n-1道的概率 }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
- 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)
- bootstrap之$.Event用法
- HTML5基础04----HTML5属性使用方法
- JSP之include指令和动作
- HDU 2586 How far away ?(LCA模板 最近公共祖先啊)
- socket阻塞与非阻塞,同步与异步
- poj 2151 Check the difficulty of problems- DP
- HDU-2675 Equation Again
- 普利司通总裁:不断引进先进产品和销售渠道经验
- JDBC MYSQL 学习笔记(一) JDBC 基本使用
- UILabel设置多种字体、颜色
- HDU 1047 Integer Inquiry【大数】
- Fiddler 教程
- The Exchange of Items (141 - ZOJ Monthly, July 2015 - E 最小费用最大流)
- Native library not found! Please copy ibbdpush_v2_3.so into your project!