Maths Olympiad Prep

Library / /25 of 53

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+jni + j \le n. (posed by Li Weigu)

Solution

Define a set
S(p,q,n)={ip+jqi and j are nonnegative integers with i+jn} 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(2nr+3)2,if nr, 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,n1){ip+(ni)qi=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+(ni)q=(i+q)p+(npi)q, ip + (n - i)q = (i + q)p + (n - p - i)q,
with
(i+q)+(npi)=n+qpn1. (i+q) + (n-p-i) = n+q-p \le n-1.
Hence number ip+(ni)qip + (n-i)q belongs to both sets S(p,q,n)S(p, q, n) and S(p,q,n1)S(p, q, n-1) if and only if npi0n-p-i \ge 0, or inpi \le n-p. Therefore,
S(p,q,n)S(p,q,n1)={{ip+(ni)qi=np+1,np+2,,n},if np,{ip+(ni)qi=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
snsn1={p,if np,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+(s1s0)++(snsn1) 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, sp1=p(p+1)2s_{p-1} = \frac{p(p+1)}{2}. If npn \ge p, we conclude that
sn=sp1+(spsp1)++(snsn1)=p(p+1)2+(np+1)p=p(2np+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,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement and solution reproduced as published; topic and difficulty added by this site.