Three. (50 points) If a positive integer $n$ has the sum of its digits in base 3 divisible by 3, then $n$ is called a "proper number." Find the sum of all proper numbers in $S=\{1,2, \cdots, 2005\}$.
For $m \in \mathbf{N}$, in ternary (base 3) representation, there are $3^{m+1}$ non-negative integers with at most $m+1$ digits. Let the number of these integers whose digit sums are congruent to 0, 1, and 2 modulo 3 be $a_{m}$, $b_{m}$, and $c_{m}$, respectively. When $m \geqslant 1$, by classifying the numbers whose digit sums are congruent to 0 modulo 3 according to their leading digit (0, 1, 2) (for numbers with fewer than $m+1$ digits, prepend leading zeros to make them $m+1$ digits long, and similarly for the following), we easily get
$$
a_{m}=a_{m-1}+b_{m-1}+c_{m-1}.
$$
Similarly,
$$
b_{m}=a_{m-1}+b_{m-1}+c_{m-1},
$$
$$
c_{m}=a_{m-1}+b_{m-1}+c_{m-1}.
$$

Thus, $a_{m}=b_{m}=c_{m}=3^{m} (m \geqslant 1)$. Clearly, $a_{0}=b_{0}=c_{0}=1$, so for $m \in \mathbf{N}$, we always have $a_{m}=b_{m}=c_{m}=3^{m}$. Therefore, in ternary representation, there are $3^{m}-1$ appropriate numbers with at most $m+1$ digits.

For $m \in \mathbf{N}$, among the $3^{m+1}$ non-negative integers with at most $m+1$ digits in binary (base 2) representation, let the sums of the numbers whose digit sums are congruent to 0, 1, and 2 modulo 3 be $A_{m}$, $B_{m}$, and $C_{m}$, respectively. Then $A_{m}+B_{m}+C_{m}$ equals the sum of these $3^{m+1}$ numbers, i.e.,
$$
\begin{array}{l}
A_{m}+B_{m}+C_{m}=1+2+\cdots+\left(3^{m+1}-1\right) \\
=\frac{1}{2} \times 3^{m+1}\left(3^{m+1}-1\right).
\end{array}
$$

When $m \geqslant 1$, among the $a_{m}$ numbers whose digit sums are congruent to 0 modulo 3, the sum of the $a_{m-1}$ numbers with leading digit 0 is $A_{m-1}$, the sum of the $c_{m-1}$ numbers with leading digit 1 is $1 \times 3^{m} c_{m-1}+C_{m-1}=3^{2 m-1}+C_{m-1}$, and the sum of the $b_{m-1}$ numbers with leading digit 2 is $2 \times 3^{m} b_{m-1}+B_{m-1}=2 \times 3^{2 m-1}+B_{m-1}$. Thus,
$$
\begin{array}{l}
A_{m}=A_{m-1}+3^{2 m-1}+C_{m-1}+2 \times 3^{2 m-1}+B_{m-1} \\
=3^{2 m}+A_{m-1}+B_{m-1}+C_{m-1}=3^{2 m}+\frac{1}{2} \times 3^{m}\left(3^{m}-1\right) \\
=\frac{1}{2} \times 3^{m}\left(3^{m+1}-1\right)(m \geqslant 1).
\end{array}
$$

Therefore, the sum of the $3^{m}-1$ appropriate numbers with at most $m+1$ digits in ternary representation is $\frac{1}{2} \times 3^{m}\left(3^{m+1}-1\right)(m \geqslant 1)$.

Since $2005=(2202021)_{3}$ is a 7-digit number, and from the previous analysis, among the positive integers with at most 7 digits, there are $3^{6}-1$ appropriate numbers, and their sum is $\frac{1}{2} \times 3^{6}\left(3^{7}-1\right)=796797$. This sum includes 60 appropriate numbers that are greater than $(2202021)_{3}$ and less than or equal to $(2222222)_{3}$. Arranging these 60 numbers in ascending order, we get
$$
\begin{array}{l}
(2202102)_{3},(2202111)_{3},(2202120)_{3}, \\
(2202201)_{3},(2202210)_{3},(2202222)_{3} ; \\
(2210001)_{3},(2210010)_{3},(2210022)_{3}, \\
(2210100)_{3},(2210112)_{3},(2210121)_{3} ; \\
(2210202)_{3},(2210211)_{3},(2210220)_{3}, \\
(2211000)_{3},(2211012)_{3},(2211021)_{3} ; \\
(2211102)_{3},(2211111)_{3},(2211120)_{3}, \\
(2211201)_{3},(2211210)_{3},(2211222)_{3} ; \\
(2212002)_{3},(2212011)_{3},(2212020)_{3}, \\
(2212101)_{3},(2212110)_{3},(2212122)_{3}, \\
(2212200)_{3},(2212212)_{3},(2212221)_{3} ; \\
(2220000)_{3},(2220012)_{3},(2220021)_{3}, \\
(2220102)_{3},(2220111)_{3},(2220120)_{3}, \\
(2220201)_{3},(2220210)_{3},(2220222)_{3} ; \\
(2221002)_{3},(2221011)_{3},(2221020)_{3} \\
(2221101)_{3},(2221110)_{3},(2221122)_{3} ; \\
(2221200)_{3},(2221212)_{3},(2221221)_{3}, \\
(2222001)_{3},(2222010)_{3},(2222022)_{3} ; \\
(2222100)_{3},(2222112)_{3},(2222121)_{3} \\
(2222202)_{3},(2222211)_{3},(2222220)_{3} ;
\end{array}
$$

It is easy to calculate that the sum of these 60 numbers is
$$
\begin{array}{r}
120 \times\left(3^{6}+3^{5}\right)+81 \times 3^{4}+(18 \times 1+24 \times 2) \times \\
3^{3}+(21 \times 1+21 \times 2) \times 3^{2}+60 \times(3+1)=125790 .
\end{array}
$$

Therefore, the sum of all appropriate numbers in $S=\{1,2, \cdots, 2005\}$ is $796797-125790=671007$.
(Fang Tinggang, Chengdu No. 7 High School, Chengdu, Sichuan, 610041)