What I need to show is that
For $\gcd(ab,p)=1$ and p is a prime, the number of solutions of the equation $ax^2+by^2\equiv 1\pmod{p}$ is exactly $$p-\left(\frac{-ab}{p}\right)\,.$$
I got a hint that I have to use Legendre symbol from the answer.
I think that I may count a solution one by one.
What I did :
$$(ax)^2 \equiv a-aby^2 \pmod{p}$$ It suffices to count $y$ such that $(\frac{a-aby^2}{p})=1$.
I tried to use the complete residue system or a primitive root but it didn't work.
The factorization also didn't work.
I think that the pigeonhole principle may not work because it just says the existence.
Thanks in advance.
Using Legendre symbol, the number of solutions can be written as $$ \sum_{y=0}^{p-1} \left(1+\left(\frac{a-aby^2}{p}\right)\right),$$ since if $a-aby^2$ is nonzero square, you have to count two solutions in $x$, and if $a-aby^2$ is zero, then you have to count one solution in $x$ (namely 0), and if $a-aby^2$ is non-square, then no solutions.
Then rewrite the summation of second term as $$ \sum_{y=0}^{p-1} \left(\frac{a-aby^2}{p}\right)=\left(\frac{-ab}{p}\right)\sum_{y=0}^{p-1}\left(\frac{y^2+d}{p}\right),$$ where $d=-b^*$ ($b^*$ is the inverse of $b$ modulo $p$)
The summation on the right, can be rewritten as $$\sum_{y=0}^{p-1} \left(1+\left(\frac{y}{p}\right)\right)\left(\frac{y+d}{p}\right)$$
Then the sum over single Legendre symbol is zero, but it remains to compute $$\sum_{y=0}^{p-1}\left(\frac{y}{p}\right)\left(\frac{y+d}{p}\right)$$
This one involves a trick: using $\left(\frac{y^*}{p}\right)$ instead of $\left(\frac{y}{p}\right)$
Then you will find that $$\sum_{y=0}^{p-1}\left(\frac{y}{p}\right)\left(\frac{y+d}{p}\right)=-1$$
Now, putting all together, you get the desired answer.