Example 7 Let $p(x)$ be a polynomial of degree $2n$, satisfying $p(0)=p(2)=\cdots=p(2n)=0, p(1)=p(3)$ $=\cdots=p(2n-1)=2$, and $p(2n+1)=-30$. Find $n$ and $p(x)$.


Analyzing the construction of the polynomial $Q(x)=p(x)-1$, then $Q(k)=(-1)^{k+1}, k=0,1,2, \cdots, 2 n$. Using the Lagrange interpolation formula to uniquely represent $Q(x)$, and substituting $x=2 n+1$, we simplify and solve.

Solution: Let $Q(x)=p(x)-1$, then $\operatorname{deg} Q=2 n$, and $Q(k)=(-1)^{k+1}, k=0,1,2, \cdots, 2 n$. By the Lagrange interpolation formula, we have $Q(x)=\sum_{k=0}^{2 n} Q\left(x_{k}\right) \prod_{\substack{i \in k \\ 0 \leqslant 1 \leqslant 2 n}} \frac{x-x_{i}}{x_{k}-x_{i}}$, where $x_{k}=k, k=0,1,2, \cdots, 2 n$. Substituting $x=2 n+1$ into the above formula, we get
$$
\begin{aligned}
Q(2 n+1) & =\sum_{k=0}^{2 n}(-1)^{k+1} \prod_{0 \leqslant k} \frac{2 n+1-i}{k-i} \\
& =\sum_{k=0}^{2 n}(-1)^{k-1}(-1)^{2 n-k} \frac{(2 n+1) \cdots(2 n+2-k)(2 n-k) \cdots 1}{k!(2 n-k) \cdots 1} \\
& =\sum_{k=0}^{2 n}(-1)^{2 n+1} \frac{(2 n+1) \cdots(2 n+1-k+1)}{k!} \\
& =-\sum_{k=0}^{2 n} C_{2 n+1}^{k}=-\sum_{k=0}^{2 n+1} C_{2 n+1}^{k}+1=-2^{2 n+1}+1 .
\end{aligned}
$$

Therefore, $p(2 n+1)=Q(2 n+1)+1=2-2 \cdot 4^{n}$. Given the condition $p(2 n+1)=-30$, we have $2-2 \cdot 4^{n}=-30$, solving for $n$ gives $n=2$, so $\operatorname{deg} p=4$. At this point, by the given conditions $p(0)=p(2)=p(4)=0$, we can set $p(x)=A x(x-2)(x-4)\left(x-x_{0}\right)$.
Using $p(1)=p(3)=2$, we get $\left\{\begin{array}{l}3 A\left(1-x_{0}\right)=2 \\ -3 A\left(3-x_{0}\right)=2\end{array}\right.$,
Solving for $A$ and $x_{0}$, we get $A=-\frac{2}{3}, x_{0}=2$. Therefore, $p(x)=-\frac{2}{3} x(x-2)^{2}(x-4)$.