5. There are two classes of primary school students going to the Youth Palace for an activity, but there is only one vehicle to pick them up and drop them off. When the first class of students gets on the vehicle and leaves the school, the second class of students starts walking; the vehicle stops at some point along the way, and the first class of students gets off to walk, while the vehicle immediately returns to pick up the second class of students and drives directly to the Youth Palace. The students' walking speed is 4 kilometers per hour, the vehicle's speed when carrying students is 40 kilometers per hour, and the vehicle's speed when empty is 50 kilometers per hour. Question: To ensure that both classes of students arrive at the Youth Palace at the same time, what fraction of the total distance did the first class of students walk? (Assume no time is spent on getting on and off the vehicle.)
5.【Solution】First, note that since students from both classes walk part of the way and ride part of the way, and the speed of the vehicle is faster than walking, with no stops in between, both classes must arrive at the Youth Palace at the same time. Therefore, the distance walked by the students from both classes must be the same.

We draw a circle (see the figure above) to analyze, where $\mathrm{A}$ is the school, $\mathrm{B}$ is the Youth Palace, $\mathrm{C}$ is the point where the first class students get off the bus, and $\mathrm{D}$ is the point where the second class students get on the bus. As mentioned above, $\mathrm{AD}$ and $\mathrm{CH}$ are the same length. Suppose when the first class students get off the bus, the second class students have walked to point $\mathrm{E}$. Since the speed of the bus when carrying students is 40 kilometers per hour, and the walking speed is 4 kilometers per hour, which is $\frac{1}{10}$ of the bus speed, $\mathrm{AE}$ is $\frac{1}{10}$ of $\mathrm{AC}$. After the first class students get off the bus, the bus drives from $\mathrm{C}$ towards the second class students. The bus speed is 50 kilometers per hour, and the second class students walk from $\mathrm{E}$ at a speed of 4 kilometers per hour. The bus and the second class students meet at point $\mathrm{D}$. It is not difficult to calculate that $\mathrm{ED}$ is $\frac{4}{54}$ of $\mathrm{EC}$. Since $\mathrm{EC}$ is $\frac{9}{10}$ of $\mathrm{AC}$ (which is $1 - \frac{1}{10} = \frac{9}{10}$),

it follows that $\mathrm{ED}$ is $\frac{4}{54} \times \frac{9}{10} = \frac{1}{15}$ of $\mathrm{AC}$. Thus, $\mathrm{AD}$ is $\frac{1}{10} + \frac{1}{15} = \frac{1}{6}$ of $\mathrm{AC}$.

Finally, since $\mathrm{AD} = \mathrm{CB}$, $\mathrm{AD}$ is $\frac{1}{6} \div \left(1 + \frac{1}{6}\right) = \frac{1}{7}$ of $\mathrm{AB}$.

Answer: The first class students walked $\frac{1}{7}$ of the total distance.