The formula used to determine density is density = mass / volume
so first you will need to determine the volume of the block which can be determined by the formula
volume = Length * Width * Height
and since the block is 3cm on each side its volume will be 27 cm cubed
so the density will be 54 g / 27 cm cubed
giving you an answer of 2 grams/cubic centimeter
(remember units are important)