Example 9 Given $a_{n}-7 a_{n-1}+10 a_{n-2}=3^{n}, a_{0}$ $=0, a_{1}=1$. Find $a_{n}$.
Solution: The characteristic equation is $x^{2}-7 x+10=0$, with roots $x_{1}=5, x_{2}=2$. Therefore, the homogeneous solution is
$$
a_{n}^{(h)}=A_{1} \cdot 2^{n}+A_{2} \cdot 5^{n} \text {. }
$$

Assume the particular solution is $a_{n}^{(p)}=p \cdot 3^{n}$. Substituting into the original recurrence relation gives $p=-\frac{9}{2}$. Hence, the general solution is
$$
a_{n}=A_{1} \cdot 2^{n}+A_{2} \cdot 5^{n}-\frac{9}{2} \cdot 3^{n} \text {. }
$$

From the initial conditions
$$
\begin{array}{l}
\left\{\begin{array}{l}
A_{1}+A_{2}-\frac{9}{2}=0, \\
2 A_{1}+5 A_{2}-\frac{27}{2}=1
\end{array}\right. \\
\Rightarrow A_{1}=\frac{8}{3}, A_{2}=\frac{11}{6} .
\end{array}
$$

Therefore, the general term is $a_{n}=\frac{8}{3} \cdot 2^{n}+\frac{11}{6} \cdot 5^{n}-\frac{9}{2} \cdot 3^{n}$.
Note: If $f(r)=\beta^{r}$, and $\beta$ is not a characteristic root, then $a_{n}^{(p)}=p \cdot \beta^{r}$. If $\beta$ is a $(m-1)$-fold characteristic root, then
$$
a_{n}^{(p)}=\left(p_{1} r^{m-1}+p_{2} r^{m-2}+\cdots+p_{m}\right) \beta^{r} .
$$

where $p_{1}, p_{2}, \cdots, p_{m}$ are to be determined.
Proof: $x_{3}=1+x_{2}-\frac{1}{2} x_{2}^{2}$