What are the dimensions of a cube if the weight is 20grams?

That depends on the density of the material in the cube. It would be different if, say, the cube were made of ice, iron, or gold.