if and only if (multiple by 4a): -the 'if and only if' is true since (4a, p)=1 - or equivalently: that is (1)
From here it is obvious that implies either or
Conversely if either or we can see that our congruence is solvable as follows:
1. If our congruence ( remember (1) ) holds if now is solvable since (2a, p)=1. Thus our congruence is solvable.
2. If we have for some and it is enough to take: which is solvable since (2a, p)=1