For a given integer $d$, let us define $S = \{m^{2}+dn^{2}| m, n \in\mathbb{Z}\}$. Suppose that $p, q$ are two elements of $S$ , where $p$ is prime and $p | q$. Prove that $r = q/p$ also belongs to $S$ .
Problem
Source: 11-th Hungary-Israel Binational Mathematical Competition 2000
Tags: number theory proposed, number theory