Example 14 The coefficients $a_{0}, a_{1}, \cdots, a_{n}$ of the polynomial $a_{0}+a_{1} x+\cdots+a_{n} x^{n}$ take values +1 or -1, and the equation $a_{0}+a_{1} x+\cdots+a_{n} x^{n}=0$ has all real roots. Find all polynomials with the above properties.
(29th Putnam Problem)
Obviously, the polynomial we are looking for is neither the zero polynomial nor a zero-degree polynomial. Let the degree of the polynomial we are looking for be $n$.

When $n=1$, the four possible polynomials are: $\pm(x+1), \pm(x-1)$, all of which meet the requirements.

When $n \geqslant 2$, let the roots of equation (1) be $x_{1}, x_{2}, \cdots, x_{n}$, then
$$
x_{1}^{2}+x_{2}^{2}+\cdots+x_{n}^{2}=\left(x_{1}+\cdots+x_{n}\right)^{2}-2\left(x_{1} x_{2}+\cdots+x_{n-1} x_{n}\right).
$$

By Vieta's formulas, we have
$$
x_{1}^{2}+x_{2}^{2}+\cdots+x_{n}^{2}=\left(-\frac{a_{n-1}}{a_{n}}\right)^{2}-2 \cdot \frac{a_{n-2}}{a_{n}}=1-\frac{2 a_{n-2}}{a_{n}} \text { and } x_{1}^{2} \cdot x_{2}^{2} \cdots x_{n}^{2}=\left(\frac{a_{0}}{a_{n}}\right)^{2}=
$$
1.
Also, by the arithmetic mean inequality, we get
$$
\frac{1-2 \frac{a_{n-1}}{a_{n}}}{n}=\frac{x_{1}^{2}+\cdots+x_{n}^{2}}{n} \geqslant \sqrt[n]{x_{1}^{2} \cdot x_{2}^{2} \cdots x_{n}^{2}}=1,
$$

which implies $\frac{a_{n-2}}{a_{n}} \leqslant \frac{1-n}{2}$,
where equality holds if and only if $x_{1}^{2}=x_{2}^{2}=\cdots=x_{n}^{2}$. However, $a_{n-2}, a_{n}$ can only take values 1 or -1, so
$$
\frac{a_{n-2}}{a_{n}} \geqslant-1 \text {, thus }-1 \leqslant \frac{1-n}{2} \Rightarrow n \leqslant 3 \text {. }
$$

When $n=2$, from (2) we get $\frac{a_{0}}{a_{2}} \leqslant-\frac{1}{2}$, so $\frac{a_{0}}{a_{2}}=-1$, meaning $a_{0}, a_{2}$ have opposite signs. In this case, $a_{1}=1$ or -1, and the four possible polynomials are: $\pm\left(x^{2}+x-1\right), \pm\left(x^{2}-x-1\right)$, all of which meet the requirements.

When $n=3$, then the equality in (2) holds, at this time $a_{1}$ and $a_{3}$ have opposite signs, and $x_{1}^{2}=x_{2}^{2}=x_{3}^{2}, x_{1}^{2} \cdot x_{2}^{2} \cdot x_{3}^{2}=1$, thus the roots of equation (1) are +1 or -1. Also, $x_{1}+x_{2}+x_{3}=-\frac{a_{2}}{a_{3}}= \pm 1$, meaning $a_{2}$ and $a_{3}$ have the same or opposite signs, but $x_{1}, x_{2}, x_{3}$ cannot all be 1, nor can they all be -1, so the roots of equation (1) are either $1,1,-1$ or $1,-1,-1$. Thus, $x_{1} \cdot x_{2} \cdot x_{3}=-\frac{a_{0}}{a_{3}}= \pm 1$, indicating that $a_{3}$ and $a_{0}$ have the same or opposite signs. In this case, we get four polynomials: $\pm\left(x^{3}+x^{2}-x-1\right), \pm\left(x^{3}-x^{2}-x+1\right)$, all of which meet the requirements.

In summary, there are 12 polynomials that meet the requirements.