4. If the surface areas of three cubes with integer edge lengths (unit: $\mathrm{cm}$) sum up to $564 \mathrm{~cm}^{2}$, then the sum of the volumes of these three cubes is ( ).
(A) $764 \mathrm{~cm}^{3}$ or $586 \mathrm{~cm}^{3}$
(B) $764 \mathrm{~cm}^{3}$
(C) $586 \mathrm{~cm}^{3}$ or $564 \mathrm{~cm}^{3}$
(D) $586 \mathrm{~cm}^{3}$
4.A.

Let the edge lengths of the three cubes be $a$, $b$, and $c$. Then $6\left(a^{2}+b^{2}+c^{2}\right)=564 \Rightarrow a^{2}+b^{2}+c^{2}=94$.
Assume without loss of generality that $1 \leqslant a \leqslant b \leqslant c \leqslant 31$.
Thus, $6 \leqslant c < 10$. Therefore, $c$ can only be $9, 8, 7, 6$.
If $c=9$, then $a^{2}+b^{2}=94-9^{2}=13$. It is easy to see that $a=2, b=3$, yielding the solution $(a, b, c)=(2,3,9)$.

If $c=8$, then $a^{2}+b^{2}=94-64=30, b \leqslant 5$. But $2 b^{2} \geqslant 30, b \geqslant 4$, thus, $b=4$ or $5$. If $b=5$, then $a^{2}=5$ has no solution; if $b=4$, then $a^{2}=14$ has no solution. Thus, there is no solution in this case.

If $c=7$, then $a^{2}+b^{2}=94-49=45$, with the unique solution $a=3, b=6$.

If $c=6$, then $a^{2}+b^{2}=94-36=58$. In this case, $2 b^{2} \geqslant a^{2}+b^{2}=58, b^{2} \geqslant 29$. Hence, $b \geqslant 6$, but $b \leqslant c = 6$, so $b=6$. At this point, $a^{2}=58-36=22$, which has no solution.
In summary, there are two solutions:
$$
(a, b, c)=(2,3,9),(3,6,7).
$$

The volumes are $V_{1}=764 \mathrm{~cm}^{3}$ or $V_{2}=586 \mathrm{~cm}^{3}$.