hdu 4405 Aeroplane chess (期望dp)
2014-01-29 13:45
274 查看
分析:
dp[i]表示走到第i(0....n)个grid时所走的步数。
根据 简述期望问题的解法来推就行了。
dp[i]表示走到第i(0....n)个grid时所走的步数。
根据 简述期望问题的解法来推就行了。
#include<cstdio> #include<iostream> #include<cstring> using namespace std; int hash[100010]; double dp[100010]; int main() { int n,m,x,y; while(scanf("%d%d",&n,&m)!=EOF) { if(n==0 && m==0) break; memset(hash,-1,sizeof(hash)); for(int i=0;i<m;i++) { scanf("%d%d",&x,&y); hash[x]=y; } memset(dp,0,sizeof(dp)); for(int i=n-1;i>=0;i--) { if(hash[i]!=-1) dp[i]=dp[hash[i]]; else { for(int 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(期望DP)
- HDU 4405 Aeroplane chess(概率dp,数学期望)
- HDU 4405 Aeroplane chess(12年金华网络赛-F题-期望DP)
- HDU 4405 Aeroplane chess(期望dp)
- HDU 4405 Aeroplane chess(期望DP)
- 【期望dp】hdu 4405 Aeroplane chess
- 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