Non-squarefree version of Pell's equation? Suppose I wanted to solve (for x and y) an equation of the form $x^2-dp^2y^2=1$ where d is squarefree and p is a prime.  Of course I could simply generate the solutions to the Pell equation $x^2-dy^2=1$ and check if the value of y was divisible by $p^2,$ but that would be slow.  Any better ideas?
It would be useful to be able to distinguish cases where the equation is solvable from cases where it is unsolvable, even without finding an explicit solution.

A different and important way to view this equation is still as a norm equation, only in a non-maximal order of the quadratic field - namely, we are looking at the ring $\mathbb{Z}[p\sqrt{d}]$.
Since we are still in the realm of algebra, we can prove results algebraically. For example:
Proposition. Let $p$ be a prime that doesn't divide $d$, and $e=x+y\sqrt{d}$ be a unit with integer $x,y$. Then $e^{p-(d/p)} \in \mathbb{Z}[p\sqrt{d}]$, where $(d/p)$ is the Legendre symbol.
Proof. If the Legendre symbol is $-1$, this means that $(p)$ doesn't split in $O$ (which will denote the maximal order from here on), so that $O/(p)$ is isomorphic to the finite field of size $p^2$. Now every number in $\mathbb{F}_{p^2}$ has order dividing $p^2-1$, so $e^{p+1} \pmod{p}$ has order diving $p-1$. But the numbers of order diving $p-1$ are exactly those in the subfield $\mathbb{F}_p$, and that means that $e^{p+1} = z+pw\sqrt{d}$, proving the claim in this case.
If $(p)$ splits into $\pi_1 \pi_2$, then $O/(p)$ is isomorphic to $O/\pi_1 \pi_2$ which is in turn, by chinese remainder theorem, isomorphic to $\mathbb{F}_p \oplus \mathbb{F}_p$. By inspection we see that the galois action permutes the two coordinates. So, since under the isomorphism $e^{p-1}\pmod{\pi_1}=e^{p-1}\pmod{\pi_2}=1$, we see that $e^{p-1}\pmod{p}$ is invariant. Hence it is of the form $z+pw\sqrt{d}$, proving the claim in this case as well. $\Box$
The above proposition shows how to get solutions to the non-squarefree Pell equation from solutions of the squarefree one - simply power appropriately.
