标签:bottom while define include turn style start expect key
http://acm.hdu.edu.cn/showproblem.php?pid=4405
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4090 Accepted Submission(s):
2607
#include<cstdio> #include<cstring> #define N 100001 using namespace std; int fly[N]; double dp[N]; int main() { int n,m,x,y; while(scanf("%d%d",&n,&m)!=EOF) { if(!n) return 0; memset(fly,0,sizeof(fly)); memset(dp,0,sizeof(dp)); while(m--) { scanf("%d%d",&x,&y); fly[x]=y; } for(int i=n-1;i>=0;i--) { if(fly[i]) dp[i]=dp[fly[i]]; else { for(int j=1;j<=6;j++) if(i+j<n) dp[i]+=dp[i+j]; dp[i]=dp[i]/6.0+1; } } printf("%.4lf\n",dp[0]); } }
标签:bottom while define include turn style start expect key
原文地址:http://www.cnblogs.com/TheRoadToTheGold/p/6921439.html