Channel
Test instructions: Vampires in a cave everywhere, he has the initial combat effectiveness, if the combat effectiveness is greater than the C value of the cave he can take time to escape, or his fighting force increased c, and then randomly choose the next cave to go, ask him to spend time to go out of the expectation
Idea: Set Dp[v], which represents the expectation when the capability value is v. So the equation is easy to write, dp[v] = sum{ti/n} (v to escape) + Sum {(1 + dp[v + c[i])/n} (next escape); For road I, if V is greater than the limit of road I, then you can use Ti to escape, the probability of {1/n} otherwise can only enter the next Days of the attempt, so need time for Dp[v + c[i]] + 1, the probability is {1/n};
Code:
#include <iostream>#include<cstdio>#include<string.h>#include<math.h>using namespacestd;#defineN 20005Doubledp[n],t;intc[ the],n,f;DoubleDfsintv) { inti,j; if(dp[v]>0)returnDp[v]; for(i=0; i<n;i++) { if(v>C[i]) {Dp[v]=dp[v]+int(T*c[i]*c[i]) *1.0/N; } Else{Dp[v]=dp[v]+ (1+dfs (V+c[i])) *1.0/N; } } returndp[v];}intMain () {inti,j; T=(1.0+SQRT (5.0))/2.0; while(~SCANF ("%d%d",&n,&f)) {memset (DP,0,sizeof(DP)); for(i=0; i<n;i++) scanf ("%d",&B[i]); printf ("%.3lf\n", DFS (f)); } return 0;}
View Code
"Expect DP" ZOJ 3640 help Me Escape