Not let's try this in 3-D. Calculate r and a relationship from the following figure.
If a=x∗r, type x.
From the figure we notice that the spheres are touching each other and the faces of the cube. The centers of the spheres are in a straight line.
So, we can infer that the side of the cube is equal to the sum of the diameters of the 2 spheres.
That means, a = 2d
⇒ a = 4r
⇒ x = 4