This topic needs to be taken into consideration from the whole. For the charging station and the terminal point N + 1, the shortest time to reach them must be directly reached after the power is finished at a certain point in front of them. Using t [I] to record the shortest distance to point I, t [I] is from 0 --> (I-1) the minimum value of the time when these vertices are fully charged. [Cpp] # include <stdio. h> int L, N, C, T, Vr, Vt1, Vt2, q [111]; double t [111]; void time () {int I, j; double min, tim; for (I = 1; I <= N + 1; I ++) {if (C> = q [I]) min = 1.0 * q [I]/Vt1; else min = 1.0 * C/Vt1 + 1.0 * (q [I]-C)/Vt2; for (j = 1; j <I; j ++) {if (C> = q [I]-q [j]) tim = 1.0 * (q [I]-q [j]) /Vt1 + 1.0 * t [j] + 1.0 * T; else tim = 1.0 * C/Vt1 + 1.0 * (q [I]-q [j]-C) /Vt2 + 1.0 * t [j] + 1.0 * T; if (tim <min) min = tim;} t [I] = min ;}} int main () {int k; double Tr, Tt; While (scanf ("% d", & L )! = EOF) {scanf ("% d", & N, & C, & T, & Vr, & Vt1, & Vt2 ); for (k = 1; k <= N; k ++) {scanf ("% d", & q [k]);} q [N + 1] = L; time (); Tr = 1.0 * L/Vr; Tt = t [N + 1]; if (Tr <Tt) printf ("Good job, rabbit! \ N "); else printf (" What a pity rabbit! \ N ") ;}return 0 ;}