Necessary and sufficient conditions for the existence of periodic solution to singular problems with impulses