Example 7 Let the terms of the sequence $\left\{a_{n}\right\}$ be
$$
0, \underbrace{1,1, \cdots, 1}_{k i}, \underbrace{2,2, \cdots,}_{k \uparrow}, 2 \underbrace{3,3, \cdots, 3}_{k \uparrow}, \cdots \text {. }
$$

Find $a_{n}$ and $S_{n}$. When $k=3$, calculate the values of $a_{2002}$ and $S_{2002}$.
Solution: This problem can be regarded as an equal-segment increment sequence, the sum of the first $m$ segments is
$$
1+\underbrace{k+k+\cdots+k}_{(m-1)+}=k(m-1)+1 .
$$

It is evident that, if and only if
$$
k(m-1)+2 \leqslant n \leqslant k m+1
$$

then, $a_{n}=m$. Solving the inequality (6) for $m$, we get
$\frac{n-1}{k} \leqslant m \leqslant \frac{n+k-2}{k}$, the same term has $m(m=1,2, \cdots)$ terms.
$$
\because 0<\frac{n+k-2}{k}-\frac{n-1}{h}<1 \text {, }
$$
$\therefore m$ is the integer part of ${ }^{n}+h-2$, denoted as
$$
m=\left[\frac{n+k-2}{k}\right] \text {. }
$$

Thus, $a_{n}=\left[\frac{n+k-2}{k}\right](k \geqslant 2)$.
When $k=3$,
$$
a_{n}=\left[\frac{n+1}{3}\right], a_{2003}=\left[\frac{2003}{3}\right]=667 \text {. }
$$

Therefore, the sum of the first $n$ segments of the sequence $a_{n}$ is
$$
\begin{array}{l}
S_{n \in \mathrm{E}}=0+1 \cdot k+2 \cdot k+\cdots+(n-1) k \\
=k[1+2+\cdots+(n-1)]=\frac{k}{2} n(n-1) .
\end{array}
$$

Replacing $n$ with $m$, the sum of the first $m$ segments is
$$
\begin{array}{l}
S_{k(m-1)+1}=\frac{1}{2} k m(m-1) . \\
\because a_{n}=\left[\frac{n+k-2}{k}\right],
\end{array}
$$
$\therefore$ the sum of the first $n$ terms of the sequence $\left\{a_{n}\right\}$ is
$$
\begin{array}{l}
S_{n}=S_{k(m-1)+1}+[(n-1)-k(m-1)] m \\
=\frac{1}{2} k(m-1) m+m n-m-k m(m-1) \\
=m n-m-\frac{1}{2} k m(m-1),
\end{array}
$$

where $m=\left[\frac{n+k-2}{k}\right]$.
When $k=3$, $S_{n}=m n-m-\frac{3}{2} m(m-1)$.
$$
\begin{array}{l}
\text { Also, } \because m=\left[\frac{2003}{3}\right]=667, \\
\begin{array}{l} 
\therefore S_{2002}= 667 \times 2002-667 \\
-\frac{3}{2} \times 667 \times(667-1) \\
=1335334-667-666333=668334 .
\end{array}
\end{array}
$$