HDU 3853 LOOPS——期望dp

网友投稿 450 2022-11-28

HDU 3853 LOOPS——期望dp

HDU 3853 LOOPS——期望dp

水题

#include #include #include #include using namespace std;const int maxn = 1010;double eps = 1e-4;int r, c;double p1[maxn][maxn], p2[maxn][maxn], p3[maxn][maxn];double dp[maxn][maxn];int main() { while (~scanf("%d%d", &r, &c)) { for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) scanf("%lf%lf%lf", &p1[i][j],&p2[i][j],&p3[i][j]); } memset(dp, 0, sizeof(dp)); for (int i = r; i >= 1; i--) { for (int j = c; j >= 1; j--) { if (1-p1[i][j] < eps) dp[i][j] = 0; else dp[i][j] = (p2[i][j]*dp[i][j+1]+p3[i][j]*dp[i+1][j]+2)/(1-p1[i][j]); } } printf("%.3f\n", dp[1][1]); } return 0;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:浅谈Mybatis传参类型如何确定
下一篇:POJ 2151 Check the difficulty of problems——概率dp
相关文章

 发表评论

暂时没有评论,来抢沙发吧~