hdu3853LOOPS概率dp
2014-08-16 22:57
211 查看
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> using namespace std; const int N=1005; const double eps=1e-9; int r,c; double p1 ,p2 ,p3 ,dp ; int main() { while(scanf("%d%d",&r,&c)!=EOF){ memset(dp,0,sizeof(dp)); for(int i=0;i<r;i++) for(int j=0;j<c;j++) scanf("%lf%lf%lf",&p1[i][j],&p2[i][j],&p3[i][j]); int j; for(int i=r-1;i>=0;i--)//(i==r-1&&j==c-1)把这个放到这里====bug for(j=c-1;j>=0;j--){ if((i==r-1&&j==c-1)||fabs(p1[i][j]-1.0)<eps) continue; dp[i][j]=(dp[i][j+1]*p2[i][j]+dp[i+1][j]*p3[i][j]+2)/(1-p1[i][j]); } printf("%.3lf\n",dp[0][0]); } return 0; }
相关文章推荐
- HDU3853LOOPS (师傅逃亡系列•三)(基础概率DP)
- hdu4089 Activation (概率dp)
- hdu3853(概率dp)
- HDU 4089 Activation (概率DP )
- hdu4035 树上概率dp
- HDU 4418 高斯消元法求概率DP
- Uva11468(AC自动机+概率dp)
- poj3557(概率dp)
- UVA 11600 Masud Rana(概率dp)
- Uva 11427 Expect the Expected 概率dp 求数学期望
- POJ 2151 概率DP
- POJ 2096 Collecting Bugs 马尔可夫链 概率DP
- poj3557 一个很巧妙的概率dp
- 【BZOJ 2318】 2318: Spoj4060 game with probability Problem(概率DP)
- hdu 4089 概率dp
- [HDOJ 4865] Peter's Hobby [概率DP]
- 【概率DP】SRM515 NewItemShop
- HDU 4870 Rating(概率dp+高斯消元)
- HDU 4035 Maze 树形概率DP 2011年成都网络赛E题
- 【概率DP】 CF 148D Bag of mice