5. In a square composed of $7 \times 7$ small squares, mark the centers of $K$ small squares such that no four points form the vertices of a rectangle whose sides are parallel to the sides of the square. What is the maximum possible value of $K$?
5. Consider an $m \times m$ square, let $x_{i}$ be the number of centers of small squares in the $i$-th row that meet the condition, then $\sum_{i=1}^{m} x_{i} = k$. If the centers of two squares are marked in a certain row, then in any other row, the centers of two squares in the same columns cannot be marked. In the $i$-th row, there are $\frac{1}{2} x_{i}(x_{i}-1)$ pairs of marked squares. Since the pairs of marked squares in each row are different, we have
$$
\sum_{i=1}^{m} \frac{x_{i}(x_{i}-1)}{2} \leqslant \frac{m(m-1)}{2}, \text{ thus } \sum_{i=1}^{m} x_{i}^{2} \leqslant
$$
$m(m-1) + \sum_{i=1}^{m} x_{i} = m(m-1) + k$, and since $\sum_{i=1}^{m} x_{i}^{2} \geqslant \frac{(x_{1} + \cdots + x_{m})^{2}}{m} = \frac{k^{2}}{m}$,

we have $\frac{k^{2}}{m} \leqslant m(m-1) + k$, solving for $k$ gives $k \leqslant \frac{1}{2}(m + m \sqrt{4m-3})$. When $m=7$, $k \leqslant 21$, the maximum value of $k$ is 21, as shown in the figure:
\begin{tabular}{|l|l|l|l|l|l|l|}
\hline & $*$ & $*$ & $*$ & & & \\
\hline$*$ & $*$ & & & & & $*$ \\
\hline$*$ & & $*$ & & & $*$ & \\
\hline$*$ & & & $*$ & $*$ & & \\
\hline & & & $*$ & & $*$ & $*$ \\
\hline & & $*$ & & $*$ & & $*$ \\
\hline & $*$ & & & $*$ & $*$ & \\
\hline
\end{tabular}