Maths Olympiad Prep

Library / China Girls' Mathematical Olympiad /24 of 51

China Girls' Mathematical Olympiad

Combinatorics Difficulty 6.2 National Olympiad Prove it China

Let pp and qq be two coprime positive integers, and let nn be a nonnegative integer. Determine the number of integers that can be written in the form ip+jqip + jq, where ii and jj are nonnegative integers with i+j≤ni + j \le n. (posed by Li Weigu)

Solution

Define a set
S(p,q,n)={ip+jq∣i and j are nonnegative integers with i+j≤n} S(p, q, n) = \{ip + jq \mid i \text{ and } j \text{ are nonnegative integers with } i + j \le n\}
Let sn=∣S(p,q,n)∣s_n = |S(p, q, n)|, where ∣X∣|X| denotes the number of elements in set XX. The answer of the problem is
sn={(n+1)(n+2)2,if n<r,r(2n−r+3)2,if n≥r, s_n = \begin{cases} \dfrac{(n+1)(n+2)}{2}, & \text{if } n < r, \\ \dfrac{r(2n-r+3)}{2}, & \text{if } n \ge r, \end{cases}
where r=max⁡{p,q}r = \max\{p, q\}.

Now we establish the equation (∗)(*). Without loss of generality, we assume that r=p>qr = p > q. It is easy to see that s0=∣S(p,q,0)∣=∣{0}∣=1s_0 = |S(p, q, 0)| = |\{0\}| = 1 satisfying equation (∗)(*). Note that
S(p,q,n)∖S(p,q,n−1)⊆{ip+(n−i)q∣i=0,1,…,n}. S(p, q, n) \setminus S(p, q, n-1) \subseteq \{ip + (n-i)q \mid i = 0, 1, \dots, n\}.
Note also that
ip+(n−i)q=(i+q)p+(n−p−i)q, ip + (n - i)q = (i + q)p + (n - p - i)q,
with
(i+q)+(n−p−i)=n+q−p≤n−1. (i+q) + (n-p-i) = n+q-p \le n-1.
Hence number ip+(n−i)qip + (n-i)q belongs to both sets S(p,q,n)S(p, q, n) and S(p,q,n−1)S(p, q, n-1) if and only if n−p−i≥0n-p-i \ge 0, or i≤n−pi \le n-p. Therefore,
S(p,q,n)∖S(p,q,n−1)={{ip+(n−i)q∣i=n−p+1,n−p+2,…,n},if n≥p,{ip+(n−i)q∣i=0,1,…,n},if n<p. S(p, q, n) \setminus S(p, q, n-1) = \begin{cases} \{ip + (n-i)q \mid i = n-p+1, n-p+2, \dots, n\}, & \text{if } n \ge p, \\ \{ip + (n-i)q \mid i = 0, 1, \dots, n\}, & \text{if } n < p. \end{cases}
It implies that
sn−sn−1={p,if n≥p,n+1,if n<p. s_n - s_{n-1} = \begin{cases} p, & \text{if } n \ge p, \\ n+1, & \text{if } n < p. \end{cases}
If n<pn < p, we conclude that
sn=s0+(s1−s0)+⋯+(sn−sn−1) s_n = s_0 + (s_1 - s_0) + \dots + (s_n - s_{n-1})
=1+2+⋯+(n+1)=(n+1)(n+2)2. =1+2+\cdots+(n+1)=\frac{(n+1)(n+2)}{2}.
In particular, sp−1=p(p+1)2s_{p-1} = \frac{p(p+1)}{2}. If n≥pn \ge p, we conclude that
sn=sp−1+(sp−sp−1)+⋯+(sn−sn−1)=p(p+1)2+(n−p+1)p=p(2n−p+3)2. \begin{aligned} s_n &= s_{p-1} + (s_p - s_{p-1}) + \cdots + (s_n - s_{n-1}) \\ &= \frac{p(p+1)}{2} + (n-p+1)p = \frac{p(2n-p+3)}{2}. \end{aligned}

Want a route through all this instead of an archive? The track puts 2,604 problems in a working order, from Junior Challenge level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.