标签:iostream style sdi eof ring freopen print using url
HDU - 3853
/* dp[i][j]表示从(i,j)到出口的期望值 */ #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,m; double dp[1010][1010],v[1010][1010][3]; int main(){ //freopen("Cola.txt","r",stdin); while(scanf("%d%d",&n,&m)!=EOF){ memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%lf%lf%lf",&v[i][j][0],&v[i][j][1],&v[i][j][2]); for(int i=n;i>0;i--) for(int j=m;j>0;j--){ if(v[i][j][0]==1)continue; dp[i][j]=(dp[i][j+1]*v[i][j][1]+dp[i+1][j]*v[i][j][2]+2)/(1-v[i][j][0]); } printf("%.3lf\n",dp[1][1]); } }
标签:iostream style sdi eof ring freopen print using url
原文地址:http://www.cnblogs.com/thmyl/p/7351688.html