别人的代码 还是不太懂 有空多看看吧
#include<cstdio>
#define MIN(a, b) ((a)<(b)?(a):(b))
int main()
{
int l;
int n, c, t;
int vr, vt1, vt2;
int cha[110];
int i, j, dist;
double dp[110][2], rabbit, tmp; //dp[i][0] 在第i个站不充电 dp[i][1] 在第i个站充电
while(scanf("%d", &l)!=EOF)
{
scanf("%d %d %d", &n, &c, &t);
scanf("%d %d %d", &vr, &vt1, &vt2);
for(i=1; i<=n; i++)
scanf("%d", cha+i);
cha[0] = 0; //起点
cha[i++] = l; //把终点加上,这样就有了n+1个
rabbit = l*1.0/vr; //兔子跑完所需时间
dp[0][0] = dp[0][1] = 0;
for(i=1; i<=n+1; i++) //这里是到n+1,因为加上了终点
{
dp[i][0] = rabbit;
for(j=i-1; j>=0; j--) //上次在第j个站充的电 相当于从j冲了电一直开到i的
{
dist = cha[i]-cha[j];
tmp = MIN((dp[j][1] + (dist>c ? ((dist-c)*1.0/vt2 + c*1.0/vt1) : (dist*1.0/vt1))), (dp[j][0]+ dist*1.0/vt2));//d[j][0]这项
dp[i][0] = MIN(dp[i][0], tmp);
}
if(dp[i][0]>=rabbit) break;
dp[i][1] = dp[i][0] + t;
}
if(i<=n+1 || dp[n+1][0]>rabbit)
printf("Good job,rabbit!\n");
else
printf("What a pity rabbit!\n");
}
}