3. Let $f(x)=\cos (\omega x)$ have the smallest positive period of 6, then the value of $f(1)+f(2)+\cdots+f(2018)$ is $($ )
A: 0
B: 1
C: $\frac{1}{2}$
D: $\frac{\sqrt{3}}{2}$
Answer A.
Analysis From the smallest positive period being 6, we know that $6 \omega=2 \pi$, i.e., $\omega=\frac{\pi}{3}$. Thus, when $k$ is an integer,
$$
f(6 k+1)+f(6 k+2)+f(6 k+3)+f(6 k+4)+f(6 k+5)+f(6 k+6)=0
$$

This means the sum of the 6 function values within each complete period is zero. Note that $2018=6 \times 336+2$, so
$$
\text { Original expression }=f(1)+f(2)=\cos \frac{\pi}{3}+\cos \frac{2 \pi}{3}=0
$$