HDU 4405 概率期望DP
2014-11-18 14:37
232 查看
有 0到 n 个格子,掷骰子走路,求出到终点的数学期望,有飞行的路线。
dp[i] 存储在i位置走到终点的期望,
转移方程dp[i]=(dp[i+1] ----> dp[i+6])/6+1;
有飞行路线则直接赋值
dp[i] 存储在i位置走到终点的期望,
转移方程dp[i]=(dp[i+1] ----> dp[i+6])/6+1;
有飞行路线则直接赋值
#include "stdio.h" #include "string.h" double dp[100010]; int hash[100010]; int main() { int n,m,x,y,i,j; while (scanf("%d%d",&n,&m)!=EOF) { if (n+m==0) break; memset(hash,-1,sizeof(hash)); while (m--) { scanf("%d%d",&x,&y); hash[x]=y; } memset(dp,0,sizeof(dp)); for (i=n-1;i>=0;i--) { if (hash[i]!=-1) dp[i]=dp[hash[i]]; else { for (j=1;j<=6;j++) dp[i]+=dp[i+j]; dp[i]=dp[i]/6+1; } } printf("%.4lf\n",dp[0]); } return 0; }
相关文章推荐
- HDU 4405 Aeroplane chess (概率DP求期望)
- HDU-4405 Aeroplane chess(概率DP求期望)
- hdu 4405 Aeroplane chess 2012年金华区域赛网络赛 概率dp求期望
- hdu 4405 Aeroplane chess(简单概率dp 求期望)
- HDU 4405 Aeroplane chess (概率DP & 期望)
- hdu 4405 Aeroplane chess(概率DP 求期望__附求期望讲解方法)
- [hdu 4405] Aeroplane chess [概率DP & 期望]
- HDU 4405 Aeroplane chess 概率dp求期望
- hdu 4405 Aeroplane chess【概率DP求期望】
- HDU 4405 - Aeroplane chess (概率DP 求期望)
- HDU 4405 Aeroplane chess(概率DP求期望)
- HDU 4405 Aeroplane chess(概率DP求期望)
- HDU 4405 Aeroplane chess(概率DP求期望)
- HDU 4405 Aeroplane chess (概率-期望DP)【模板】
- HDU 4405 Aeroplane chess(全期望公式-概率dp)
- hdu 4405 概率dp 求期望
- HDU 4405 Aeroplane chess (概率DP求期望)
- HDU 4405 Aeroplane chess(概率dp,数学期望)
- hdu 4405 Aeroplane chess (概率DP+求期望)
- 概率DP求期望入门,HDU 4405,POj 2096,HDU 3853