5. If the expansion of $\left(1+x+x^{2}\right)^{1000}$ is $a_{0}+a_{1} x+a_{2} x^{2}+\cdots+a_{2000} x^{2000}$, then the value of $a_{0}+a_{3}+$ $a_{6}+a_{9}+\cdots+a_{1998}$ is
A. $3^{333}$
B. $3^{666}$
C. $3^{999}$
D. $3^{2001}$
Take $x=1, \omega, \omega^{2}$, where $\omega=-\frac{1}{2}+\frac{\sqrt{3}}{2} \mathrm{i}$, satisfying $\omega^{3}=1$ and $1+\omega+\omega^{2}=0$.
Thus, $\left\{\begin{array}{l}a_{0}+a_{1}+a_{2}+\cdots+a_{2000}=3^{1000}, \\ a_{0}+a_{1} \omega+a_{2} \omega^{2}+\cdots+a_{2000} \omega^{2000}=0, \\ a_{0}+a_{1} \omega^{2}+a_{2} \omega^{4}+\cdots+a_{2000} \omega^{4000}=0 .\end{array}\right.$
(1) + (2) + (3) gives $3\left(a_{0}+a_{3}+a_{6}+a_{9}+\cdots+a_{1998}\right)=3^{1000}$
$\Rightarrow a_{0}+a_{3}+a_{6}+a_{9}+\cdots+a_{1998}=3^{999}$. Therefore, the answer is $C$.