\(A = area\,of\,cross - section\,of\,cylinder\)
Using law of floatation,
\(Weight\,of\,cylinder = Upthrust\,by\,two\,liquids\)
\(L \times A \times d \times g = n\rho \times \left( {pL \times A} \right)g + \rho \left( {L - pL} \right)Ag\)
\(d = np\rho + \rho \left( {1 - p} \right) = \left( {np + 1 - p} \right)\rho \)
\(d = \left\{ {1 + \left( {n - 1} \right)p} \right\}\rho \)