  This paper deals with the investigation of $K$-contact and
$(\kappa,\mu)$-contact manifolds admitting a positive smooth function $f$
satisfying the equation: $$f\mathring{Ric}=\mathring{\nabla}^2f$$ where
$\mathring{Ric}$, $\mathring{\nabla}^2f$ are traceless Ricci tensor and Hessian
tensor respectively. We proved that if a complete and simply connected
$K$-contact manifold admits such a smooth function $f$, then it is isometric to
the unit sphere $\mathbb{S}^{2n+1}$. Next, we showed that if a non-Sasakian
$(\kappa,\mu)$-contact metric manifold admit such a smooth function $f$, then
it is locally flat for $n=1$ and for $n>1$ is locally isometric to the product
space $E^{n+1}\times S^n(4)$.
