Test instructions
Give n points, and each point has a treasure.
You start at the point of 1, assuming that you are at the I point, each random walk 1~min (6,n-i) step.
Take the treasure every point you arrive.
Ask for the last hope of getting the treasure.
Ideas:
The topic of the water.
Dp[n]=v[n]
Then push forward one by one.
Just note that the number of steps is 1~min (6,n-i)
Code:
#include "cstdlib" #include "Cstdio" #include "CString" #include "Cmath" #include "queue" #include "algorithm" #include " iostream "#include" map "#include" stack "#include" vector "#define LL __int64#define inf-999999999999999999llusing namespace Std;int Main () { int t,cas=1; cin>>t; while (t--) { int n; scanf ("%d", &n); int v[123]; Double dp[123]; for (int i=1;i<=n;i++) scanf ("%d", &v[i]); Memset (Dp,0,sizeof (DP)); Dp[n]=v[n]; for (int i=n-1;i>=1;i--) { int cnt=min (6,n-i); Dp[i]=v[i]; for (int j=1;j<=cnt;j++) { dp[i]+=1.0/cnt*dp[i+j]; } } printf ("Case%d:%.7f\n", cas++,dp[1]); } return 0;}
[water + desired DP] Light OJ 1030 discovering Gold