An atom at the corner of the cube contributes 18 to the unit cell. Hence, number of atoms of A in the unit cell =8×18=1.
An atom at the face of the cube contributes 12 to the unit cell.
Hence, number of atoms of B in the unit cell =6×12=3.
Thus, the formula is AB3.