A compound is formed by two elements X and Y. Atoms of the element Y (as anions) make ccp and those of element X (as cations) occupy all the octahedral voids the formula for the compound is:
XY
The ccp lattice is formed by the element Y. The number of octahedral voids generated would be equal to the no of atoms of Y present in it. Since all the octahedral voids are occupied by the atoms of X, the number would also be equal to that of the element Y. Therefore the formula of the compound is XY.