hdu4405 Aeroplane chess(期望dp)
2015-05-27 01:25
323 查看
题意:已知起点(0)和可选步数(1,2…6),每次选择一种走法。且存在一些点之间连通,可以直达。
求第一次大于等于n的期望步数。
解法:简单的期望dp
求第一次大于等于n的期望步数。
解法:简单的期望dp
#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> #include<math.h> #include<set> #include<vector> #include<map> #define ll long long using namespace std; const int maxn = 100000+10; int n,m; int vis[maxn]; double dp[maxn]; int main(){ while(scanf("%d%d",&n,&m)!=EOF){ if(n==0&&m==0) break; memset(dp,0,sizeof(dp)); memset(vis,0,sizeof(vis)); for(int i=1;i<=m;i++){ int x,y; scanf("%d%d",&x,&y); vis[x]=y; } for(int i=n-1;i>=0;i--){ if(vis[i]){ dp[i]=dp[vis[i]]; } else{ double tmp=0.0; for(int k=1;k<=6;k++){ tmp+=dp[i+k]; } dp[i]=tmp/6.0+1.0; } } printf("%.4lf\n",dp[0]); } return 0; }
相关文章推荐
- 【HDU4405】Aeroplane chess [期望DP]
- HDU4405:Aeroplane chess(概率dp & 期望)
- hdu4405 Aeroplane chess 【期望dp】
- HDU4405-Aeroplane chess(概率DP求期望)
- hdu4405[Aeroplane chess] 有点懂了期望概率DP
- 【期望DP】HDU4405 Aeroplane chess
- hdu4405 Aeroplane chess【概率DP+期望问题】
- [hdu4405]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求期望)
- HDU4405-Aeroplane chess(可能性DP需求预期)
- HDU 4405 Aeroplane chess 期望dp
- 简单概率dp(期望)-hdu-4405-Aeroplane chess
- hdu 4405 Aeroplane chess 2012年金华区域赛网络赛 概率dp求期望
- HDOJ 4405 Aeroplane chess(期望DP)
- HDU4405 Areoplane chess(期望dp)
- HDU 4405 Aeroplane chess 概率dp求期望