Problem 4. The Dursleys are hiding Harry Potter on an island that is 9 km from the shore. The shore is straight. On the shore, 15 kilometers from the point on the shore closest to the island, Hagrid is on a magical motorcycle and wants to reach Harry as quickly as possible. The motorcycle travels along the shore at a speed of $50 \mathrm{km} /$ hour, and over the sea at a speed of 40 km/hour. Hagrid's plan is: first travel $X$ kilometers along the shore, and then head straight for the island. What value of $X$ is best suited for Hagrid's purposes?
# Answer: 3.

Solution. Let $A$ be the point from which Hagrid starts, $B$ be the island, and $C$ be the point where the motorcycle crashes into the sea. The travel time is $t=\frac{A C}{50}+\frac{B C}{40}=p A C+q B C=q\left(\frac{p}{q} A C+B C\right)$, where $p=\frac{1}{50}, q=\frac{1}{40}$. Thus, we aim to minimize $\frac{p}{q} A C+B C$. Mark an arbitrary point $D$ on the shore, construct a circle with $A D$ as the diameter and radius $q \cdot s: 2$ (where $s$ is arbitrary). Draw a circle centered at $D$ with radius $p \cdot s$, and let this circle intersect the first on land at point $E$. Drop a perpendicular $B F$ from $A E$, and it will intersect the shoreline at the optimal point $C$.

We will prove that $\frac{p}{q} A C+B C$ is minimal. From the similarity of triangles $A F C$ and $A E D$, it follows that $C F / A C=D E / A D=\frac{p}{q}, C F=\frac{p}{q} A C$, which means $\frac{p}{q} A C+B C=B F$. If we take any other point $M$ on the shore and calculate $\frac{p}{q} A M+B M$, we get the following: $\frac{p}{q} A M+B M=K M+M B$, where $K M$ is the perpendicular from $K$ to $A E$. And in turn, $K M+M B>B K>B F$.

Let $L$ be the point on the shore closest to the island. Triangles $B C L$ and $A C F$ are similar, from which $C L=\frac{B L \cdot C F}{A F}$. Therefore, $C L=12$ and $A C=X=3$.