Suppose that the set $\{1,2,\cdots, 1998\}$ has been partitioned into disjoint pairs $\{a_i,b_i\}$ ($1\leq i\leq 999$) so that for all $i$, $|a_i-b_i|$ equals $1$ or $6$. Prove that the sum \[ |a_1-b_1|+|a_2-b_2|+\cdots +|a_{999}-b_{999}| \] ends in the digit $9$.
Problem
Source: USAMO 1998
Tags: modular arithmetic, number theory proposed, number theory
15.12.2005 07:00
WLOG, we may assume $a_i > b_i$ or we can just switch $a_i$ and $b_i$. So the sum just becomes $\sum a_i - \sum b_i$. But we know $\sum a_i + \sum b_i = \frac{1998 \cdot 1999}{2} = 999 \cdot 1999$ is odd. So $\sum a_i - \sum b_i$ is odd as well. Since $\sum a_i - \sum b_i$ is the sum of $999$ $1$'s or $6$'s and is odd, we know there must be an even number of $6$'s. Let $2x$ be the number of $6$'s. Then $\sum a_i - \sum b_i = 6(2x)+1(999-2x) = 10x + 999 \equiv 9 \pmod{10}$ as desired. QED.
17.12.2005 09:33
Assume WLOG that $6=b_1-a_1=\cdots=b_k-a_k$ and $1=b_{k+1}-a_{k+1}=\cdots=b_n-a_n$. For $i,j\le k$, we say that $\{a_j,b_j\}$ links onto $\{a_i,b_i\}$ if $\{a_i,b_i\}$ if $a_i<a_j<b_i<b_j$ or $a_j<a_i<b_j<b_i$. Since pair $\{a_i,b_i\}$ links onto$\{a_j,b_j\}$ if and only if $\{a_j,b_j\}$ links onto $\{a_i,b_i\}$, there are an even number of ordered pairs of integers $(i,j)$ such that pair $j$ links onto pair $i$. For a given $i\le k$, there are an odd number of integers between $a_i$ and $b_i$, so the number of pairs that link onto$\{a_i,b_i\}$ is odd. Thus, the total number of ordered pairs of integers $(i,j)$ such that pair $j$ links onto pair $i$ is congruent to \[ \sum_{i=1}^k(\text{number of pairs that link onto pair \textit{i}}) \equiv \sum_{i=1}^k 1\equiv k \bmod 2. \] Therefore, since we already know that this number is even, we find that $k$ is even, and the value of the given sum is \[ 6k+(999-k) = 999+5k\equiv 9\bmod10. \]
25.03.2008 04:10
Take the equation modulo 5. Then the sum is $ 999\cdot 1\equiv4\pmod{5}$. As shown above, the equation is odd, so the sum must be 9 mod 10.
28.04.2009 03:29
Here is one proof. I do not think it's very well written, especially the lemma (did I even need a lemma??) but here it is. (Sorry, I also didn't know how to make the congruence sign, and I was in a hurry, so I just put equal signs.)
27.12.2013 09:44
11.01.2014 03:44
18.09.2014 11:09
24.06.2017 04:17
26.08.2017 16:08
Ok my sol was overkill: Here are the two lemmas. First has been proved by many of above solutions, second is true by construction. (just need to describe it nicely.")
26.08.2017 22:30
Let $k$ of the differences be six, and let the rest be one. Let $A$, $B$, and $C$ denote the number of even-even, even-odd, and odd-odd pairs. Clearly, there are $B+2A=999$ evens, hence $B$ is odd. It follows that $k$ is even, so $5k+999\equiv 9 \mod 10$ as desired. $\square$
15.02.2021 09:50
19.03.2021 18:19
Let $S$ be the sum. Modulo $2$, \[ S = \sum |a_i-b_i| \equiv \sum (a_i+b_i) = 1 + 2 + \dots + 1998 \equiv 1 \pmod 2. \]Modulo $5$, \[ S = \sum |a_i-b_i| = 1 \cdot 999 \equiv 4 \pmod 5. \]So $S \equiv 9 \pmod{10}$.
31.03.2021 19:25
I had the same solution as @above, but I couldn't get the $1$ modulo $2$ part. Why can we add the numbers like that? (I don't really get the $1+2+...+1998$ part).
31.03.2021 20:25
@above It's because $x\equiv -x\pmod{2}$ for all integers $x$, so $|a_i-b_i|\equiv a_i-b_i\pmod{2}$ regardless of whether $a_i\ge b_i$.
05.09.2021 05:33
Mod 5, the expression is obviously 4 mod 5. Now observe that $$|a_1-b_1| \equiv a_1+b_1 \pmod 2,$$implying the desired sum is congruent to $$\sum_{i=1}^{1998} i \equiv 1 \pmod 2.$$Combining gives the result.
06.11.2021 04:44
WLOG let $a_i>b_i$ and let $a_i-b_i=d_i$. Then $d_i$ equals $1$ or $6$, and we only need to show that $$\sum_{i=1}^{999}d_i\equiv 1\pmod 2.$$Notice that $$\sum_{i=1}^{999}d_i+2\sum_{i=1}^{999}b_i=\sum_{i=1}^{999}a_i+\sum_{i=1}^{999}b_i\equiv 1\pmod 2,$$and we are done. $\blacksquare$
30.11.2021 15:12
The number $6$ comes 'even-even' or 'odd-odd'. We claim that the number of $6$'s must be even. If odd then we get greater than $999$ odd or even number, this is a contradiction because $\{1,2,\cdots 1998\}$ have $999$ even and $999$ odd. So \begin{eqnarray*} \sum _{i=1}^{999} |a_i-b_i|=6\times 2k+1\times(999-2k)\equiv 10k+999\equiv 9 \hspace{6mm} \text{(mod 10)} \end{eqnarray*}
17.12.2021 06:40
By CRT, we can break this into $\pmod{2}$ and $\pmod{5}.$ For $\pmod{2},$ note that $$|a_1-b_1| \equiv a_1+b_1 \pmod{2},$$since absolute value doesn't matter in $\pmod{2}.$ So our sum is just $1+2+...+1998 \equiv 1 \pmod{2}.$ For $\pmod{5},$ just notice that its always $1\pmod{5}$ for all of $|a_1-b_1|, |a_2-b_2|, ...$ so our answer is just $4\pmod{5}.$ Using CRT, we get an answer of $9\pmod{10}.$ $\blacksquare$
13.08.2022 07:59
Note that $|a - b| \equiv a - b \equiv a + b \pmod 2$ for all integers $a, b$. The original sum then becomes $$|a_1 - b_1| + \cdots + |a_{999} - b_{999}| \equiv a_1 + b_1 + \cdots + a_{999} + b_{999} = 1 + \cdots + 1998 \equiv 1 \pmod 2. $$ Now we have that the sum $$|a_1 - b_1| + \cdots + |a_{999} - b_{999}| \equiv \underbrace{1 + \cdots + 1}_{\text{999 times}} = 999 \equiv 4 \pmod 5. $$ Hence this sum is $1 \pmod 2$ and $4 \pmod 5$, so by CRT we have that the sum is $9 \pmod {10}$, as desired. $\blacksquare$
22.11.2022 03:03
We will consider the sum mod 2 and mod 5 we see that since $6\equiv 1\pmod 2$ the sum of 999 terms has a remainder of 1 when divided by 2 similarly we see that $6\equiv1\pmod 5$ so the sum of 999 terms has a remainder of 4 when divided by 5 so by CRT we see that the sum has a remainder of 9 when divided by 10 which implies that the units digit is 9
04.01.2023 13:56
Let the sum be $S$. Note that $S\equiv 999\cdot 1\mod 5\Longleftrightarrow S\equiv 4\mod 5$. Also note that $S$ has the same parity as $a_1+b_1+a_2+b_2+\ldots+a_{999}+b_{999}=1+\ldots+1998$ which clearly odd, so $S\equiv 1\mod 2$. Hence the remainder of $S\mod 10$ is unique by the Chinese Remainder Theorem, and it is easy to check that it is $9$ indeed.
04.01.2023 13:56
Alcumusgrinder07 wrote: We will consider the sum mod 2 and mod 5 we see that since $6\equiv 1\pmod 2$ the sum of 999 terms has a remainder of 1 when divided by 2 similarly we see that $6\equiv1\pmod 5$ so the sum of 999 terms has a remainder of 4 when divided by 5 so by CRT we see that the sum has a remainder of 9 when divided by 10 which implies that the units digit is 9 $6\equiv 1\mod 2$???
15.01.2023 18:56
Note that the expression is $4 \pmod 5$, so it suffices to show that it is odd. But notice that we have $$\left|a_i-b_i\right| \equiv a_i-b_i \pmod 2,$$and we have $1+2+3+\dots+1998 \equiv 1 \pmod 2$, which finishes.
04.08.2023 07:10
Since $1$ and $6$ differ by $5$, the ending digit is $9$ whenever there is an odd number of $i$ such that $|a_i-b_i|=1$ and is $4$ otherwise. There are $999$ odds and $999$ evens so there can't be an even number of $i$ such that $|a_i-b_i|=1$, because that would imply an even number of odds and an even number of evens. Therefore, the ending digit must be $9$.
04.08.2023 09:28
MithsApprentice wrote: Suppose that the set $\{1,2,\cdots, 1998\}$ has been partitioned into disjoint pairs $\{a_i,b_i\}$ ($1\leq i\leq 999$) so that for all $i$, $|a_i-b_i|$ equals $1$ or $6$. Prove that the sum \[ |a_1-b_1|+|a_2-b_2|+\cdots +|a_{999}-b_{999}| \]ends in the digit $9$. my teach gimme that as homework
11.09.2023 00:54
Suppose there are $x$ pairs with difference $1$. Then our sum is \[(999-x)+6x = 999+5x,\]which has units digit either $4$ or $9$. Note that this sum also has the same parity as $1 + 2 + \ldots + 1998$, which is odd, since \[\lvert a_i - b_i \rvert \equiv a_i - b_i \equiv a_i + b_i \mod 2.\] Thus our sum has units digit $9$. $\blacksquare$
06.10.2023 02:20
Clearly, the desired sum is $4\pmod 5$, so it remains to show that it’s $1\pmod 2$. Because $|a-b|\equiv a-b\equiv a+b\pmod 2$ for any integers $a$ and $b$, this means \[|a_1-b_1|+|a_2-b_2|+\dots+|a_{999}-b_{999}|\equiv 1+2+\dots + 1998\equiv 1\pmod 2\]and we are done. $\square$
06.10.2023 02:32
We note that this sum is $\equiv 4\pmod{5},$ we need to prove that this is $1 \pmod{2},$ note that $|a-b|,$ has the same parity as $a+b,$ so we need to prove $a+b \equiv 1\pmod{2},$ so $|a_1-b_1|+|a_2-b_2|+\cdots +|a_{999}-b_{999}| \equiv 1+2+3...+1998 \equiv 1\pmod{2},$ hence proved $\blacksquare$
28.10.2023 08:59
WLOG assume $a_i>b_i$ for each $i$. Notice that \[\sum a_i + \sum b_i = 999 \cdot 1999,\] which is odd. Thus, in order to have integer values, we must have that $\sum a_i - \sum b_i$ is odd. Thus, the number of $6$'s, denote as $2k$, is even. We have \[\sum a_i - \sum b_1 = 6 \cdot 2k + (999-2k) = 10k+999 \equiv 9 \pmod{10}. \ \square\]
30.12.2023 14:04
WLOG $a_i>b_i$ for all $i$. Now note that, \[ \displaystyle\sum |a_i-b_i| = \displaystyle\sum a_i - b_i \equiv \displaystyle\sum a_i + b_i = \dfrac{1998\cdot 1999}{2} \equiv 1 \pmod{2}. \] Also, \[ \displaystyle\sum a_i - b_i \equiv \displaystyle\sum 1 = 999 \equiv 4 \pmod{5}. \] Thus combining these by CRT, we get that $\displaystyle\sum |a_i-b_i| \equiv 9 \pmod{10}$.
30.12.2023 16:44
Cute.
02.01.2024 16:06
$|a_i - b_i| = 1$ or $6$. Say $|a_i - b_i| = 1$ for $k$ of these $999$ pairs. The sum would then be equal to $k + 6(999 - k) = 5994 - 5k$. Note that a pair with difference $6$ has same parity and a pair with difference $1$ does not. All pairs of difference $6$ would give us an even number of even numbers and an even number of odd numbers. If $k$ was even, that suggests there are even numbers of odd numbers and even numbers of even numbers. However, since there is a total of $999$ even numbers and $999$ odd numbers, this cannot be true. So thus, $k$ is odd, and the sum would end with digit $9$.
07.01.2024 18:59
15.02.2024 06:17
Overkill solution, but proud of it For the sake of simplicity, we will write all pairs $\{a_i, b_i\}$ such that $a_i < b_i$. Let there be $x$ six-pairs $(a_i, b_i)$ such that $|a_i - b_i|=6$. Then, there are $999-x$ one-pairs such that $|a_i - b_i| = 1$. The given expression evaluates to $$6x + (999-x) = 5x + 999$$For this to be $9 \pmod{10}$, it suffices to show that $x$ is even. Note that along with any six-pair $(n, n+6)$, in order to make successful pairings, we must have either exactly one of the six-pairs $$(n+1, n+7), (n+3, n+9), (n+5, n+11),$$or one of the following sets of three six-pairs $$\{(n+1, n+7), (n+2, n+8), (n+3, n+9)\}$$$$\{(n+1, n+7), (n+2, n+8), (n+5, n+11)\}$$$$\{(n+1, n+7), (n+4, n+10), (n+5, n+11)\}$$ Each option generates an even number of six-pairs, so $x$ is even, as desired $\blacksquare$
29.06.2024 12:52
Modulo 2, $$ |a_1-b_1|+|a_2-b_2|+\cdots +|a_{999}-b_{999}| \equiv a_1 + \cdots + a_{999} + b_1 + \cdots + b_{999}$$$$= \frac{1998 \cdot 1999}{2} \equiv 1 \pmod{2}.$$Note that $|a_i - b_i| \equiv 1 \pmod{5} \forall i$, so $$ |a_1-b_1|+|a_2-b_2|+\cdots +|a_{999}-b_{999}| \equiv 1 + \cdots + 1 \equiv 999 \equiv 4 \pmod{5}.$$Now from the Chinese Remainder Theorem, $ |a_1-b_1|+|a_2-b_2|+\cdots +|a_{999}-b_{999}| \equiv 9 \pmod{10}$. $\square$
17.08.2024 19:46
We see that each $|a_i-b_i|\equiv 1\pmod 5$, and $999\equiv 4\pmod 5$, so $|a_1-b_1|+|a_2-b_2|+\dotsb +|a_{999}-b_{999}|\equiv 4\pmod 5$. Note that the $|a_i-b_i|\equiv a_i+b_i\pmod 2$, so $|a_1-b_1|+|a_2-b_2|+\dotsb +|a_{999}-b_{999}|\equiv \frac{1998\cdot 1999}{2}\equiv 1\pmod 2$. Thus, $|a_1-b_1|+|a_2-b_2|+\dotsb +|a_{999}-b_{999}|\equiv 9\pmod {10}$. $\blacksquare$
17.08.2024 20:13
Since each $|a_i - b_i|$ is $1\pmod 5$, the sum is clearly $4\pmod 5$. It suffices to show that the sum is odd. Clearly the absolute value when taking the parity, so the sum has the same parity as $\sum a_i - \sum b_i$. Let $x = \sum a_i$. We have $\sum (a_i + b_i) = \sum a_i + \sum b_i = 1 + 2 + \cdots + 1998$ is odd, so $\sum b_i$ has the opposite parity of $\sum a_i$, implying that $\sum a_i - \sum b_i$ is odd, as desired.
17.11.2024 04:53
It is clear that $$|a_1-b_1|+|a_2-b_2|+\dotsb +|a_{999}-b_{999}|\equiv 4\pmod 5.$$The only thing left is to prove that $$|a_1-b_1|+|a_2-b_2|+\dotsb +|a_{999}-b_{999}|\equiv 1\pmod 2.$$However, $$|a_1-b_1|+|a_2-b_2|+\dotsb +|a_{999}-b_{999}|$$$$\equiv a_1-b_1+a_2-b_2+\dots+a_{999}-b_{999}$$$$\equiv a_1+b_1+a_2+b_2+\dots+a_{999}+b_{999}$$$$=\frac{1998\cdot 1999}{2}$$$$\equiv 1\pmod 2.$$
19.11.2024 01:11
Let there be $x$ pairs that sum to $6,$ and $y$ pairs that sum to $1.$ Then $x+y=999 \implies 6x+y \equiv 4 \pmod 5.$ Meanwhile, if WLOG $a_i > b_i$ for all $i,$ then our sum equals $$1998 \cdot 1999/2 - 2\sum b_i \equiv 1 \pmod 2,$$so by CRT it ends in the digit $9,$ so we are done. QED