Cube of dimensions : 8 * 8 * 8 .
If it is divided into unit cubes. we have 8^3 number of cubes = 512.
The unit cubes present at the pointed corners (vertices) of the big cube will be painted on 3 sides. There are 8 corners to the cube. So 8 unit cubes are painted on 3 sides.
The cubes present on the edges of cube, have two sides, exposed on two faces of the cube. So they will be painted in two colors. We have already taken care of the two unit cubes present on the corners. So we will have 8-2 = 6 on each edge. There are 12 edges. Hence 72 cubes are painted on two dies.
The unit cubes that are on 2nd, 3rd, 4th, 5th, 6th, 7th row and 2nd 3rd, 4th, 5th and 6th, 7th column will be exposed only one side. So they are painted only on one side. Hence, 6 X 6 = 36 unit cubes on each face. There are 6 faces of a cube. Hence, 36 * 6 = 216 unit cubes are painted on one side.
The number of cubes not painted on any side are 512 - 8 - 72 - 216 = 216 . These are inside the big cube and not exposed to outside. In fact the number can also be calculated as there are 6 * 6 * 6 in each dimension , hidden inside the big cube.