There may be an typo in (a). Your answer is:
Compute $\pi$, let $l=m-\pi[m]$, if $m \bmod l=0$ and for all $p=m-i \cdot l>0, p-\pi[p]=l$, then $\rho\left(P_i\right)=m / l$, otherwise $\rho\left(P_i\right)=1$. The running time is $\Theta(n)$
where, $P_i$ in $\rho\left(P_i\right)=m / l$ and $\rho\left(P_i\right)=1$ should be $P$ exactly (subscript $i$ should be omitted).