5. Choose D.

Slightly solved: Let the $k$-th 1 be the $b_{k}$-th term of $\left\{a_{k}\right\}$, then $b_{1}=1, b_{k+1}=b_{k}+2 k$. By the method of superposition, we can get $b_{k+1}$ $=b_{1}+2 \cdot \frac{(1+k) k}{2}=k^{2}+k+1$. Then $b_{2004}=2003^{2}+2003+1=4014013$.
5. Given a sequence $\left\{a_{n}\right\}$ where each term is 1 or 0, the first term is 1, and there are $2k-1$ zeros between the $k$-th 1 and the $(k+1)$-th 1, i.e., $1,0,1,0,0,0,1,0,0,0,0,0,1, \cdots$, then the 2004th 1 is the term number
A. 45
B. 1981
C. 4012009
D. 4014013