18. Find the coefficients of $x^{17}$ and $x^{18}$ after expanding the brackets and combining like terms in the expression

$$
\left(1+x^{5}+x^{7}\right)^{20}
$$
18. Let's repeat 20 times the trinomial $1+x^{3}+x^{7}$ and multiply it according to the usual rules. Each term of the resulting sum will represent a product of 20 factors, each equal to either 1, or $x^{5}$, or $x^{7}$. It is essential that in these products of twenty factors, any of the three expressions can stand in each of the 20 positions: the sum will contain terms that are products of all possible combinations of the specified factors (i.e., the product of 20 ones, the product of 19 ones and one factor $x^{5}$, the product of 19 ones and one factor $x^{7}$, the product of 18 ones, one factor $x^{5}$, and one factor $x^{7}$, and so on), taken in all possible orders (for example, we will have 20 different terms that are the product of 19 ones and $x^{5}$, because the factor $x^{5}$ can stand in such a product in the first, second, third, ..., twentieth position, and all these will be different terms of our sum).

All such products will represent $x$ raised to some power, which is the sum of a certain number of fives and a certain number of sevens. But it is easy to check that the number 18 cannot be represented as the sum of addends taking the values 5 and 7; hence, the term $x^{18}$ will not be present in our sum (the desired coefficient of $x^{18}$ is zero).

The number 17 can be uniquely represented as the sum of fives and sevens: $17=5+5+7$. Therefore, $x^{17}$ will be equal to those terms of our sum that are the product of two factors $x^{5}$, one factor $x^{7}$, and 17 factors 1. We need to determine the number of such products in our sum. The factor $x^{7}$ can stand in any of the 20 positions. Let's assume for definiteness that it stands in the first position. After this, there are still 19 free positions, two of which must be occupied by factors $x^{5}$, and the remaining 17 by ones. If one of the factors $x^{5}$ stands in a certain position, then the second can stand in any of the remaining 18 positions. Thus, we get 18 terms in which the first unoccupied position by $x^{7}$ (i.e., the second) is occupied by $x^{5}$, 18 terms in which the second of these free positions is occupied by $x^{5}$, 18 terms in which the third such position is occupied by $x^{5}$, and so on, finally, 18 terms in which the last (nineteenth) free position is occupied by $x^{5}$. At first glance, it seems that there are 19.18 terms of the required form in which the factor $x^{7}$ stands in the first position. However, in reality, there are half as many. Indeed, in each of these terms, the factors $x^{5}$ stand in two positions (for example, in the $i$-th and $k$-th positions), so in our count, each of these terms is counted twice (in our example, the considered term is counted among the 18 products in which the $i$-th position is occupied by $x^{5}$, and among the 18 products in which the $k$-th position is occupied by $x^{5}$). Therefore, the actual number of terms of the required form in which the factor $x^{7}$ stands in the first position is $\frac{19 \cdot 18}{2}=171$. There will be as many such terms in which $x^{7}$ stands in the second, third, ..., twentieth position. Thus, the total number of such terms, equal to the coefficient of $x^{17}$ in $\left(1+x^{\overline{5}}+x^{7}\right)^{20}$, is $20 \cdot 171=3420$.