Example 9 Let $S$ be a subset of the set $\{1,2, \cdots, 50\}$ with the following property: the sum of any two distinct elements of $S$ cannot be divisible by 7. Then, what is the maximum number of elements that $S$ can have?
(43rd American High School Mathematics Examination)
Solution: For two different natural numbers $a$ and $b$, if $7 \times (a+b)$, then the sum of the remainders when they are divided by 7 is not 0. Therefore, the set $\{1,2, \cdots, 50\}$ can be divided into 7 subsets based on the remainders when divided by 7. In $A_{i}$, each element has a remainder of $i$ when divided by 7 ($i=1,2, \cdots, 6$), then
$$
\begin{array}{l}
A_{0}=\{7,14,21,28,35,42,49\}, \\
A_{1}=\{1,8,15,22,29,36,43,50\}, \\
A_{2}=\{2,9,16,23,30,37,44\}, \\
A_{3}=\{3,10,17,24,31,38,45\}, \\
A_{4}=\{4,11,18,25,32,39,46\}, \\
A_{5}=\{5,12,19,26,33,40,47\}, \\
A_{6}=\{6,13,20,27,34,41,48\},
\end{array}
$$

According to the problem:
(1) $S$ can contain at most one element from $A_{0}$;
(2) If $S$ contains one element from $A_{i}$, then it can contain all elements from this set, but it cannot contain any elements from $A_{7-i}$;
(3) $A_{1}$ contains 8 elements, while the other subsets contain only 7 elements, so the largest subset $S$ must contain all elements from $A_{1}$.

In summary, the largest subset $S$ has $1+8+7+7=23$ elements.