If you check the picture below
the rectangular solid is a 6x6x6, so all sides are equal thus is a cube
is painted on all faces, so the only part that's painted is the faces, ok
then you split it like in the picture, you have all 6 faces painted there,
now, let's say each of those 6 faces are cut in 2cm
how many of those 2cm pieces will each have? so get that amount for each and sum them up, that's how many of the cubes have one face painted
only the cubes that are part of the face, which was painted, are the ones that have a painted face themselves
keep in mind that each face is a 6x6 rectangle
notice the 2nd picture below