Analysis: Dynamic planning, it is important to note that the current state needs to be considered together with all previous states, pay attention to the processing of floating-point numbers, but also WA once.
#include <iostream>using namespace Std;int l,n,c,t,vr,vt1,vt2;int a[105];d ouble dp[105];d ouble min_time_ij (int i _0,int j_0) {if (j_0-i_0>c) return c*1.0f/vt1+ (j_0-i_0-c) *1.0f/vt2;elsereturn (J_0-I_0) *1.0f/vt1;} int main () {int i,j;double min,value;while (cin>>l) {CIN>>N>>C>>T;CIN>>VR>>VT1 >>vt2;for (i=1;i<=n;i++) cin>>a[i];a[0]=0;a[n+1]=l; Final distance as end Dp[0];for (i=1;i<=n+1;i++) {min=1000000;for (j=0;j<i;j++) {if (j==0) //first electric vehicle has electricity value=dp[j]+min_ Time_ij (A[j],a[i]); Elsevalue=dp[j]+min_time_ij (A[j],a[i]) +t; The first J station is charged directly to I. Min=min<value?min:value;} Dp[i]=min;} if (DP[N+1]<L*1.0F/VR) cout<< "What a pity rabbit!" <<endl;elsecout<< "Good job,rabbit!" <<endl;} return 0;}
HDU ACM 2059 Turtle and Rabbit race--Dynamic planning