1 //动态规划思路 2 #include<stdio.h> 3 int a[150]; 4 double dp[150]={0}; 5 int main() 6 { 7 double min(double x,double y); 8 int len,n,maxlen,i,j,lenth; 9 double time,vmax,vmin,vr,t; 10 while(~scanf("%d%d%d%lf%lf%lf%lf",&len,&n,&maxlen,&time,&vr,&vmax,&vmin)) 11 { 12 a[0]=0; a[n+1]=len; 13 for(i=1; i<n+1; ++i) 14 scanf("%d",&a[i]); 15 for(i=1; i<=n+1; ++i) 16 { 17 dp[i]=len/vmin+1;//保证够大才能比较出最小值 18 for(j=0; j<i; ++j) 19 { 20 lenth=a[i]-a[j]; 21 if(lenth>maxlen) 22 t=maxlen/vmax+(lenth-maxlen)/vmin; 23 else 24 t=lenth/vmax; 25 t+=dp[j]; 26 if(j) 27 t+=time; 28 dp[i]=min(dp[i],t);//计算i之前j发电站到i的时间最小值 29 } 30 } 31 if(dp[n+1]<len/vr) 32 printf("What a pity rabbit! "); 33 else 34 printf("Good job,rabbit! "); 35 } 36 } 37 38 double min(double x,double y) 39 { 40 double z=x<y?x:y; 41 return z; 42 }