http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4808
Test instructions: A vampire initial attack is F. N Road, he chooses a path every time he waits for a probability. If the damage is greater than the c[i of this road], it will take t[i] days to escape ($t [i]=\frac{1+\sqrt{5}}{2} \times c[i]^2$), otherwise it takes 1 days to continue to select the route. Ask for the number of days to escape (1<=c[i], f<=10000)
#include <cstdio> #include <cmath> #include <cstring>using namespace Std;const int n=20005;double F[n] ; int n, C[n], T[n];d ouble E (int x) {if (f[x]>0) return f[x];d ouble &now=f[x];for (int i=0; i<n; ++i) {if (X>c[i] ) Now+=t[i];else now+=e (x+c[i]) +1;} Now/=n;return now;} int main () {int now;while (~scanf ("%d%d", &n, &now)) {for (int i=0; i<n; ++i) scanf ("%d", &c[i]), t[i]= (1.0+s QRT (5))/2*c[i]*c[i];p rintf ("%.3f\n", E (now)), memset (f, 0, sizeof f);} return 0;}
Simple problem without brain dp= =
Set $f[i]$ to indicate the desired number of days to escape when the attack is $i$. Just a little bit.
"ZOJ" 3640 help Me Escape