Let $S$ be the set of all ordered pairs $(a,b)$ of integers with $0<2a<2b<2017$ such that $a^2+b^2$ is a multiple of $2017$. Prove that \[\sum_{(a,b)\in S}a=\frac{1}{2}\sum_{(a,b)\in S}b.\] Proposed by Uwe Leck, Germany
Problem
Source: Baltic Way 2017 Problem 20
Tags: number theory
11.11.2017 17:49
Let $p=2017$ an $a\in\{1,...,\frac{p-1}{2}\}$. It will be shown that there exists a unique $b\in\{1,...,\frac{p-1}{2}\}$ such that $2017\mid a^2+b^2$. Since $2017$ is a prime congruent to $1$ modulo $4$ there exists $k$ such that $k^2\equiv -1\pmod{2017}$. We can choose $b\in\{1,...,\frac{p-1}{2}\}$ such that $b\equiv \pm k a\pmod{2017}$ and $0<b<\frac{p-1}{2}$. Thus $a^2+b^2\equiv0\pmod{2017}$. Assume that we have two such $b$, $b_1$ and $b_2$. Then $b_1^2\equiv b_2^2\pmod{2017}$. Thus $2017\mid (b_1-b_2)(b_1+b_2)$. Since $0<b_1+b_2<2017$, $2017\mid b_1-b_2$ and $b_1=b_2$ which proves uniqueness. Let $$S_a=\{a\,\mid\,\exists\,b:(a,b)\in S\}$$. It will be shown that $a\rightarrow b-a$ is a bijection from $S_a$ to $S_a$ itself. Note that $$(b-a)^2+(b+a)^2=2(a^2+b^2)\equiv 0\pmod{2017}$$. If $a+b>\frac{p-1}{2}$ then $0<2017-a-b\leq \frac{p-1}{2}$ and since $(a+b)^2\equiv (2017-a-b)^2\pmod{2017}$ it follows that $b-a\in S_a$. Assume that $a_1,a_2\in S_a$, $(a_1,b_1),(a_2,b_2)\in S$ and that $b_1-a_1=b_2-a_2$. Then $b_1^2+a_1^2-2a_1b_1=b_2^2+a_2^2-2a_2b_2$ thus $$a_1b_1\equiv a_2b_2\pmod{2017}.$$We now that $b_1\equiv\pm ka_1$ and $b_2\equiv \pm ka_2$ $\pmod{2017}$ so $ka_1^2\equiv\pm ka_2^2\pmod{2017}$ thus $a_1^2\equiv \pm a_2^2\pmod{2017}$. If $a_1^2\equiv -a_2^2\pmod{2017}$ then $2017\mid a_1^2+a_2^2$ and it follows by uniqueness that $b_1=a_2$ and $b_2=a_1$ which gives $a_1=a_2$. If $a_1^2\equiv a_2^2\pmod{2017}$ thus $2017\mid a_1^2-a_2^2$ and $a_1=a_2$. This proves injectivity of the map $a\rightarrow b-a$. Since it maps from a finite set to the set itself it is also a bijection. The sums can be rewritten as $$\sum_{(a,b)\in S}a=\sum_{(a,b)\in S}b-a.$$By the above it follows that both sides equals $$\sum_{a\in S_a}a$$which solves the problem.
18.03.2019 12:33
Really elegant problem! Here is my solution. Replace $2017$ with arbitrary prime $p\equiv 1\pmod 4$. First, let's get a sense of what $S$ look like. Claim 1 : If we enumerate $S = \{(a_1,b_1), (a_2,b_2),...,(a_k,b_k)\}$, then $\{a_1,a_2,...,a_k,b_1,b_2,...,b_k\} = \{1,2,3,...,\tfrac{p-1}{2}\}$ and $k=\tfrac{p-1}{4}$. Proof : Clearly it suffices to show that for each positive integer $a<\tfrac{p}{2}$ then there exists unique positive integer $b < \tfrac{p}{2}$ which $p\mid a^2+b^2$. This is fairly obvious as there exists residue $x$ such that $x^2\equiv -1\pmod p$ thus we can take $b\equiv \pm ax\pmod p$. Now we are ready to present the key idea. Claim 2 : Mapping $(a,b)\to (b-a, \min\{a+b, p-a-b\})$ is bijection from $S\to S$. Proof : First, we check that $(b-a, \min\{a+b, p-a-b\}) \in S$. Clearly $\min\{a+b, p-a-b\} < \tfrac{p}{2}$ thus it suffices to verify that $p-a-b > b-a$. Indeed, this is equivalent to $2b < p $ which is true. The divisibility relation comes from the identity $$(b-a)^2 + (b+a)^2 = 2(a^2+b^2) \equiv 0\pmod p.$$Now, we claim that the map is injection. Suppose that there exists $(a,b)\in S$, $(c,d)\in S$ such that $b-a = d-c$. Then $(a-b)^2 \equiv (c-d)^2 \pmod p$ $\implies 2ab\equiv 2cd\pmod p$ which means $$(a+b)^2 \equiv (c+d)^2 \pmod p \implies a+b \equiv \pm(c+d)\pmod p.$$If $a+b\equiv c+d\pmod p$, then we have $$(a+b) + (a-b) \equiv (c+d) + (c-d) \pmod p\implies a\equiv c\pmod p$$or $(a,c) = (b,d)$. Finally if $a+b\equiv -(c+d)\pmod p$, then $$(a+b) + (a-b) \equiv -(c+d) + (c-d) \pmod p \implies a \equiv -d\pmod p$$which is impossible as $a,d < \tfrac{p}{2}$. Hence this map is indeed injection. The problem is evident as the bijection implies $$\sum_{(a,b)\in S} a = \sum_{(a,b)\in S} b-a \implies \sum_{(a,b)\in S} a = \frac{1}{2}\sum_{(a,b)\in S} b.$$
18.03.2019 17:55
Here is another proof (Serbia apparently took this problem from Baltic Way, and this is my solution therein). First, I claim that if $Q_i=\{a_i,b_i\}$, it holds that $Q_i\cap Q_j=\varnothing$ if $j\neq i$ . To see this, assume the converse, get two elements $u,v$ with $u^2-v^2\equiv 0\pmod{p}$, $u\neq v$ and $u,v\leq \frac{p-1}{2}$, showing impossibility. Next, I claim that for any $j\in\{1,2,\dots,\frac{p-1}{2}\}$, there is a pair such that, $j$ is contained in this pair. Again, to see this, let $q^2\equiv -1\pmod{p}$, and let $b\in\mathbb{Z}_p$ with $b\equiv jq\pmod{p}$. Observe that. $b^2+j^2\equiv (p-b)^2+j^2\pmod{p}$, and since one of $b,p-b$ is smaller than $\frac{p-1}{2}$, we are done. Now, the main observation is that, $b_i-a_i\not\equiv b_j-a_j\pmod{p}$, for every $i\neq j$. To see this, take an $j\neq i$ with $b_i-a_i\equiv b_j-a_j\pmod{p}$. Taking squares yields $b_ia_i\equiv b_ja_j\pmod{p}$. As $a_i\equiv \pm qb_i\pmod{p}$ with $q^2\equiv -1\pmod{p}$, we have either $b_i^2\equiv b_j^2\pmod{p}$ (which contradicts with disjointness of pairs), or $b_i^2+b_j^2\equiv 0\pmod{p}$ (which declares, both $(b_i,b_j)$ and $(a_j,b_j)$ are valid, again, contradicting with impossibility). Hence, they are all distinct. With this, it remains to show, $\{b_i-a_i:1\leq i \leq t\}=\{a_j:1\leq j\leq t\}$. For this, we need to show that, $b_i-a_i\neq b_j$ for any $j$/. We now show how to finish. Recall we want to show that, $b_i-a_i$ correspond to an $a_j$. First, $b_i-a_i<\frac{p-1}{2}$, and thus, it must be contained in a pair. We now observe that, $p\mid (b_i-a_i)^2+(b_i+a_i)^2$. Hence, either $(b_i-a_i,b_i+a_i)$ or $(b_i-a_i,p-(b_i+a_i))$ is the pair containing $b_i-a_i$. If it is the former, since $b_i-a_i<b_i+a_i$, we are done. If not, then the corresponding pair must be $(b_i-a_i,p-(b_i+a_i))$. Now, if $b_i-a_i$ is the 'bigger' member of this pair, we must have, $b_i-a_i >p-b_i-a_i$, giving that $2b_i>p$, contradiction. Hence, $b_i-a_i$ is indeed the smaller member of this pair, and we conclude with this.