hdu 4405 简单概率dp
2014-08-31 16:38
330 查看
什么都不多说。推荐一个博客:http://kicd.blog.163.com/blog/static/126961911200910168335852/
代码如下:
代码如下:
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define MAX 101111 int n,m; int flag[MAX]; double dp[MAX]; int x,y; int main() { int i,j; while(scanf("%d%d",&n,&m)!=EOF) { if(n+m==0) break; memset(flag,0,sizeof(flag)); for(i=1;i<=m;i++) { scanf("%d%d",&x,&y); flag[x]=y; } dp =dp[n+1]=dp[n+2]=dp[n+3]=dp[n+4]=dp[n+5]=dp[n+6]=0; for(i=n-1;i>=0;i--) { if(flag[i]) { dp[i]=dp[flag[i]]; } else{ dp[i]=(dp[i+1]+dp[i+2]+dp[i+3]+dp[i+4]+dp[i+5]+dp[i+6])/6+1; } } printf("%.4f\n",dp[0]); } return 0; }
相关文章推荐
- 简单概率DP——hdu4405
- 简单概率dp(期望)-hdu-4405-Aeroplane chess
- hdu 4405(概率dp简单题)
- hdu 4405 Aeroplane chess(简单概率dp 求期望)
- 概率dp入门的简单题(hdu 4405,牡丹江,codeforces)
- hdu 4405 Aeroplane chess(概率dp)
- HDU 4405 Aeroplane chess(概率DP求期望)
- HDU 4405 Aeroplane chess (概率DP求期望)
- 简单概率dp-hdu-4487-Maximum Random Walk
- HDU 4405 - Aeroplane chess (概率DP 求期望)
- HDU 4405 Aeroplane chess(概率dp)
- HDU 4576 (概率dp的简单应用)只有两种情况
- hdu 3835 简单概率dp
- hdu 4405 概率dp 求期望
- HDU 3853LOOPS(简单概率DP)
- hdu-4405-Aeroplane chess-概率DP
- HDU 4546简单的概率 dp
- hdu 4405 概率DP
- Hdu 4405 Aeroplane chess - 简单DP
- hdu 4405 Aeroplane chess(概率dp1)