4. On a glade, two firs, each 30 meters tall, grow 20 meters apart from each other. The branches of the firs grow very densely, and among them are some that are directed straight towards each other, and the length of each branch is half the distance from it to the top. A spider can crawl up or down the trunk (strictly vertically), along the branches (strictly horizontally), or descend vertically down a web from one branch to another. What is the shortest distance the spider will have to crawl to get from the top of one fir to the top of the other?
Solution. From the diagram, it can be seen that the branches of the firs intersect at a height of no more than 10 meters from the ground. Indeed, at this height, the distance to the treetop is 20 meters, so the length of each branch is $20 / 2 = 10$ meters, and the total length of the branches of the two firs is equal to the distance between them. Therefore, the spider must descend to a height of 10 meters and then climb up. This means it has to overcome at least 40 meters vertically. Additionally, it needs to travel at least 20 meters horizontally. In total, its path will be at least 60 meters. Note that there are many paths of 60 meters (one of them is shown in black in the diagram).

![](https://cdn.mathpix.com/cropped/2024_05_06_a1908813e69e094a552eg-2.jpg?height=385&width=616&top_left_y=320&top_left_x=711)

There is another interpretation of the problem, where the path the spider traveled downward along the web is not counted (it falls rather than crawls). In this case, the answer is 40 meters (20 meters horizontally and 20 meters vertically).