zoukankan      html  css  js  c++  java
  • HDU 3853 LOOPS 可能性dp(水

    在拐~



    #include <stdio.h>
    #include <cstring>
    #include <iostream>
    #include <map>
    #include <cmath>
    template <class T>
    inline bool rd(T &ret) {
        char c; int sgn;
        if(c=getchar(),c==EOF) return 0;
        while(c!='-'&&(c<'0'||c>'9')) c=getchar();
        sgn=(c=='-')?

    -1:1; ret=(c=='-')?0:(c-'0'); while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0'); ret*=sgn; return 1; } template <class T> inline void pt(T x) { if (x <0) { putchar('-'); x = -x; } if(x>9) pt(x/10); putchar(x%10+'0'); } using namespace std; typedef unsigned long long ull; const double eps = 1e-10; const int N = 1005; int n, m; double mp[N][N][3], dp[N][N]; double solve(){ dp[n][m] = 0; for(int i = n; i ; i--) for(int j = m; j; j--) { if(i == n && j == m)continue; if(fabs(mp[i][j][0] - 1.0) < eps) { dp[i][j] = 0; } else { dp[i][j] = mp[i][j][1] * dp[i][j+1] + mp[i][j][2] * dp[i+1][j]; dp[i][j] += 2.0; dp[i][j] /= (1 - mp[i][j][0]); } } return dp[1][1]; } void input(){ for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) scanf("%lf %lf %lf", &mp[i][j][0], &mp[i][j][1], &mp[i][j][2]); } int main(){ while(cin>>n>>m){ input(); printf("%.3f ", solve()); } return 0; }



    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    Jooq基本操作
    SpringcloudStream简单使用
    SpringcloudBus消息总线
    RabbitMQ集群
    Springboot整合RabbitMQ
    RabbitMQ死信队列与延迟队列
    RabbitMQ事务性消息和确认模式
    公链简介
    公链简介
    Windows生产力工具推荐
  • 原文地址:https://www.cnblogs.com/blfshiye/p/4717392.html
Copyright © 2011-2022 走看看