4. Vasya must plant 7 trees in a row. Each planted tree is either a birch or an oak. The planting must satisfy the condition: next to each tree of one type, there must be a tree of the other type. In how many different ways can Vasya perform the planting? Two ways are different if there is a spot where different types of trees grow.
Solution. Note that by changing the type of each planted tree to another, we get another way. Two such ways will be called complementary. Thus, it is enough to count the number of such pairs of complementary ways. Which tree to plant at the edge is completely determined by its neighbor. Therefore, it is enough to determine the number of ways to plant 5 central trees (without the two edge ones). One type of tree can only be planted in a row twice (a pair). There can be a maximum of two such pairs $(3 \times 2=6>5)$, and together with the fifth tree, they determine 3 ways depending on whether the fifth is in the center or at the edge. One such pair has four possible positions. This gives us 4 more ways. And there is no pair of one type. The last way. In total, 8 ways. But this number needs to be doubled, and the answer is 16 ways.

Another solution.

We will represent trees of one type with dark circles and the other type with light circles. And we will start building the tree of planting ways, starting with a black circle. See the diagram.

Answer: 16.

What is the minimum number of faces of the cubes that Vasya should paint to prevent Petya?

## Answer: 2.

Solution. It is enough to paint two opposite faces of one cube. One painted face is not enough: Petya will "hide" it inside.

## Grading criteria.

![](https://cdn.mathpix.com/cropped/2024_05_06_6517971f8beebf62d320g-3.jpg?height=410&width=395&top_left_y=679&top_left_x=235)

Only the answer: 0 points.

The correct example of painting two faces is indicated: 6 points.

It is shown that one painted face is not enough: 1 point.

It is clear that 8 ways were obtained. But this number needs to be doubled, as black circles can be replaced with birches, and white circles with oaks, and vice versa.

## Grading criteria.

3 - 7 ways of planting are indicated: 1 point.

8 - 11 ways of planting are indicated: 2 points.

12 - 15 ways of planting are indicated: 3 points.

All ways are indicated, but it is not explained that there are no other ways: 5 points.