6. Toss a coin independently $n$ times (where $n$ is a positive integer), each time the coin only shows heads or tails. Let $a(n)$ denote the total number of scenarios where the number of times heads appear is exactly a multiple of 3, and $b(n)$ denote the total number of scenarios where the number of times heads appear is exactly a multiple of 6.
(1) Find $a(2016), b(2016)$;
(2) When $n \leqslant 2016$, find the number of positive integers $n$ such that $2 b(n) - a(n) > 0$.
(Wu Genxiu, problem contributor)
6. From the conditions, we have
$$
\begin{array}{l}
a(n)=\mathrm{C}_{n}^{0}+\mathrm{C}_{n}^{3}+\cdots+\mathrm{C}_{n}^{3 k}+\cdots, \\
b(n)=\mathrm{C}_{n}^{0}+\mathrm{C}_{n}^{6}+\cdots+\mathrm{C}_{n}^{6 k}+\cdots .
\end{array}
$$

Let the three roots of $z^{3}=1$ be $z_{k}=\mathrm{e}^{\frac{2 \pi}{3} \mathrm{i}}(k=1,2,3)$.
Then, for any positive integer $n$, we have
$$
\begin{array}{l}
\sum_{k=1}^{3} z_{k}^{n}=\left\{\begin{array}{l}
3, n \equiv 0(\bmod 3) ; \\
0, n \neq 0(\bmod 3) .
\end{array}\right. \\
\text { Then } \sum_{k=1}^{3}\left(1+z_{k}\right)^{n}=\sum_{k=1}^{3} \sum_{j=0}^{n} \mathrm{C}_{n}^{j} z_{k}^{j} \\
=\sum_{j=0}^{n} \mathrm{C}_{n}^{j}\left(\sum_{k=1}^{3} z_{k}^{j}\right)=\sum_{\substack{j=0 \\
31 j}}^{n} 3 \mathrm{C}_{n}^{j}=3 a(n) .
\end{array}
$$

It is known that
$$
\begin{array}{l}
1+z_{1}=\mathrm{e}^{\frac{\pi}{3} \mathrm{i}}, 1+z_{2}=\mathrm{e}^{-\frac{\pi}{3} \mathrm{i}}, 1+z_{3}=2 . \\
\text { Hence } a(n)=\frac{1}{3} \sum_{k=1}^{3}\left(1+z_{k}\right)^{n} \\
=\frac{1}{3}\left(\mathrm{e}^{\frac{\pi \pi}{3} \mathrm{i}}+\mathrm{e}^{-\frac{\pi \pi}{3} \mathrm{i}}+2^{n}\right) \\
=\frac{1}{3}\left(2^{n}+2 \cos \frac{n \pi}{3}\right) .
\end{array}
$$

Similarly, let the six roots of $z^{6}=1$ be
$$
\begin{array}{l}
\omega_{k}=\mathrm{e}^{\frac{k \pi}{3} \mathrm{i}}(k=1,2, \cdots, 6) \text {. } \\
\text { Then by } \sum_{k=1}^{6} \omega_{k}^{n}=\left\{\begin{array}{ll}
6, & n \equiv 0(\bmod 6) ; \\
0, & n \neq 0(\bmod 6),
\end{array}\right. \\
\sum_{k=1}^{6}\left(1+\omega_{k}\right)^{n}=6 b(n) \text {. } \\
\text { Also, } 1+\omega_{1}=\sqrt{3} \mathrm{e}^{\frac{\pi}{6} \mathrm{i}}, 1+\omega_{2}=\mathrm{e}^{\frac{\pi}{3} \mathrm{i}}, 1+\omega_{3}=0 \text {, } \\
1+\omega_{4}=e^{-\frac{\pi}{3} i}, 1+\omega_{5}=\sqrt{3} e^{-\frac{\pi}{6} i}, 1+\omega_{6}=2 \text {, } \\
\end{array}
$$

we get
$$
\begin{array}{l}
b(n)=\frac{1}{6} \sum_{k=1}^{6}\left(1+\omega_{k}\right)^{n} \\
=\frac{1}{6}\left[2^{n}+2(\sqrt{3})^{n} \cos \frac{n \pi}{6}+2 \cos \frac{n \pi}{3}\right] .
\end{array}
$$
(1) When $n=2016$, from equations (1) and (2) we have
$$
\begin{array}{l}
a(2016)=\frac{1}{3}\left(2^{2016}+2\right), \\
b(2016)=\frac{1}{6}\left[2^{2016}+2(\sqrt{3})^{2016}+2\right] \\
=\frac{1}{6}\left(2^{2016}+2 \times 3^{1008}+2\right) .
\end{array}
$$
(2) Combining equations (1) and (2), we get
$$
\begin{array}{l} 
2 b(n)-a(n) \\
= \frac{1}{3}\left[2^{n}+2(\sqrt{3})^{n} \cos \frac{n \pi}{6}+2 \cos \frac{n \pi}{3}\right]- \\
\frac{1}{3}\left(2^{n}+2 \cos \frac{n \pi}{3}\right) \\
= \frac{2(\sqrt{3})^{n}}{3} \cos \frac{n \pi}{6} .
\end{array}
$$

Then for any positive integer $n$, we have
$$
\begin{array}{l}
2 b(n)-a(n)>0 \Leftrightarrow \cos \frac{n \pi}{6}>0 \\
\Leftrightarrow n \equiv 0, \pm 1, \pm 2(\bmod 12) .
\end{array}
$$

Thus, in each complete residue system modulo 12, there are exactly five numbers that satisfy the condition.
Noting that 12 | 2016,
the number of positive integers $n$ that satisfy the condition is
$$
\frac{5}{12} \times 2016=840
$$