Example 1 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)
For two different natural numbers $a$ and $b$, if $7 \times (a+b)$, then the sum of their remainders when 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. Among them, each element in $K_{i}$ has a remainder of $i$ when divided by 7 ($i=1,2, \cdots, 6, 0$), then
$$
\begin{array}{l}
K_{1}=\{1,8,15,22,29,36,43,50\}, \\
K_{2}=\{2,9,16,23,30,37,44\}, \\
K_{3}=\{3,10,17,24,31,38,45\}, \\
K_{4}=\{4,11,18,25,32,39,46\}, \\
K_{5}=\{5,12,19,26,33,40,47\}, \\
K_{6}=\{6,13,20,27,34,41,48\}, \\
K_{0}=\{7,14,21,28,35,42,49\} .
\end{array}
$$

From the problem, we get
(1) If $S$ contains one element from $K_{i} (i=1,2, \cdots, 6)$, then it can contain all elements of this set, but it cannot contain elements from $K_{7-i}$ at the same time;
(2) $S$ can contain at most one element from $K_{0}$;
(3) The largest subset $S$ must contain all elements of $K_{1}$.
Thus, $S=K_{1} \cup K_{2} \cup K_{3} \cup \{7\}$ is the largest set that meets the requirements, and the maximum number of elements in $S$ is
$$
8+7+7+1=23 \text{. }
$$