Example 6 Let $n$ be a positive integer, and the sequence $A: a_{1}, a_{2}, \cdots$, $a_{n}$ be a sequence composed of 0 or 1, that is,
$a_{k}=0$ or $1(1 \leqslant k \leqslant n)$.
Find the number of sequences such that $\sum_{i=1}^{n} a_{i}$ leaves a remainder of 3 when divided by 4.
Let $f(x)=(1+x)^{n}=\sum_{i=0}^{n} b_{i} x^{i}$.
It is easy to see that the number of $A$ is $S=b_{3}+b_{7}+b_{11}+\cdots$. Let $\omega$ be a fourth root of unity, and without loss of generality, let $\omega=\mathrm{i}, 1+\omega+\omega^{2}+\omega^{3}=0$.
Then $x f(x)=\sum_{i=0}^{n} b_{i} x^{i+1}$.
Substituting $1, \omega, \omega^{2}, \omega^{3}$ into equation (1) and adding them up, we get
$$
\begin{array}{l}
f(1)+\omega f(\omega)+\omega^{2} f\left(\omega^{2}\right)+\omega^{3} f\left(\omega^{3}\right) \\
=b_{0}\left(1+\omega+\omega^{2}+\omega^{3}\right)+ \\
b_{1}\left(1+\omega^{2}+\omega^{4}+\omega^{6}\right)+4 S .
\end{array}
$$

Thus, $4 S=f(1)+\mathrm{i} f(\mathrm{i})+\mathrm{i}^{2} f\left(\mathrm{i}^{2}\right)+\mathrm{i}^{3} f\left(\mathrm{i}^{3}\right)$ $=2^{n}+\mathrm{i}(1+\mathrm{i})^{n}-\mathrm{i}(1-\mathrm{i})^{n}$. Also, $(1+\mathrm{i})^{2}=2 \mathrm{i},(1-\mathrm{i})^{2}=-2 \mathrm{i}$, so $(1+\mathrm{i})^{4 k}=(1-\mathrm{i})^{4 k}=(-4)^{k}$.
When $n=4 k$, $S=\frac{2^{4 k}}{4}$;
When $n=4 k+1$, $S=\frac{2^{4 k}-(-4)^{k}}{2}$;
When $n=4 k+2$, $S=2^{4 k}-(-4)^{k}$;
When $n=4 k+3$, $S=2^{4 k+1}-(-4)^{k}$.