标签:
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2059
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12248 Accepted Submission(s): 4593
1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 5 const double INF = 10000000.0; 6 7 int main () 8 { 9 int N,i,j; 10 double L,C,T,v1,v2,v3; 11 double a[111],dp[111]; 12 while (scanf ("%lf",&L)==1) 13 { 14 scanf ("%d%lf%lf",&N,&C,&T); 15 scanf ("%lf%lf%lf",&v1,&v2,&v3); 16 for (i=1; i<=N; i++) 17 scanf ("%lf",&a[i]); 18 a[0] = dp[0] = 0.0; 19 a[N+1] = L;//加入起点和终点 20 for (i=1; i<=N+1; i++) 21 { 22 double Min = INF; 23 for (j=0; j<i; j++) 24 { 25 double t, len = a[i] - a[j]; 26 if (len > C) 27 t = C / v2 + (a[i] - a[j] - C) / v3; 28 else 29 t = (a[i] - a[j]) / v2; 30 if (j)//起点不需要充电,故不用加T 31 t += T; 32 Min = min(Min, dp[j] + t);//取最小时间 33 } 34 dp[i] = Min; 35 } 36 if (L / v1 > dp[N+1]) 37 printf ("What a pity rabbit!\n"); 38 else 39 printf ("Good job,rabbit!\n"); 40 } 41 return 0; 42 }
标签:
原文地址:http://www.cnblogs.com/dxd-success/p/4255512.html