We shall prove that the solutions are the triples (a,b,c) such that a divides b and b divides c. We denote by ((x0,y0,z0),p,q,r) the parallelepiped with a low right vertex (x0,y0,z0) and dimensions p,q and r, at axes Ox,Oy and Oz, respectively.
Let us assume that b is not divisible by a, i.e. b=ma+n for some m,n∈N, 0<n<a. If (p,q,r) is a permutation of (a,b,c), then it follows from the condition for the parallelepipeds ((0,0,0),p,q,r) and ((0,0,1),p,q,r) that the parallelepipeds ((0,0,0),p,q,1) and ((0,0,r),p,q,1) are filled with cubes of the same colors. This implies that the parallelepipeds ((0,0,0),c,a,1) and ((0,0,b),c,a,1) are also filled with cubes of the same colors and the same is true for the parallelepipeds ((0,0,0),c,b,1) and ((0,0,ma),c,b,1). Since ((0,0,0),c,b,1) contains ((0,0,0),c,a,1) and ((0,0,ma),c,b,a) contains ((0,0,ma),c,b,1) and ((0,0,b),c,a,1), every color in ((0,0,0),c,a,1) appears at least two times in ((0,0,ma),c,b,a). This contradiction completes the proof that a divides b. We analogously see that b divides c.
Now let a∣b and b∣c, as b=p1a,c=p2b=p1p2a, where p1,p2∈N. For every two positive integers m and n we denote by R(m,n) the remainder of m modulo n. The coordinates of a cube will be the coordinates of its low right vertex.
We determine the color the cube (x,y,z) in remainders as follows:
(R(x,a);R(y,a);R(z,a);R(⌊ax⌋+⌊ay⌋,p1);R(⌊ay⌋+⌊az⌋,p1);R(⌊bx⌋+⌊by⌋+⌊bz⌋,p2)).
The counting of all possible remainders in the six coordinates shows that the number of the colors used is a3p1p1p2=abc.
Let us assume that two distinct cubes (x1,y1,z1) and (x2,y2,z2) lie in a parallelepiped of dimensions a×b×c. Then we have ∣x1−x2∣≤α, ∣y1−y2∣≤β and ∣z1−z2∣≤γ, where (α,β,γ) is a permutation of (a,b,c). Since ∣x1−x2∣, ∣y1−y2∣ and ∣z1−z2∣ are divisible by a, one of these numbers equals 0. Let us have x1=x2. Then the fourth and fifth coordinates of that color show that ∣y1−y2∣ and ∣z1−z2∣ are divisible by b and therefore one of these two numbers equals 0. If, for example, y1=y2, then the last coordinate shows that ∣z1−z2∣ is divisible by c, i.e. z1=z2. We obtained (x1,y1,z1)≡(x2,y2,z2), which is a contradiction.