Maths Olympiad Prep

Library / /345 of 397

, 2022

Number theory Difficulty 6.9 National Olympiad Prove it Taiwan

Consider two coprime positive integers p,qp, q, and for i=1,2,,q1i = 1, 2, \dots, q-1, define f(i)f(i) to be the remainder when pip \cdot i is divided by qq. If f(i)f(i) is the largest number among f(1),f(2),,f(i)f(1), f(2), \dots, f(i), then ii is called a big number; but if f(i)f(i) is the smallest number among f(1),f(2),,f(i)f(1), f(2), \dots, f(i), then ii is called a small number. Note that 1 is both a big number and a small number.
Given two positive integers a,ba, b. It is known that among 1,2,,q11, 2, \dots, q-1 there are aa big numbers and bb small numbers, find the least possible value of qq.

Solution

The least possible number for qq is ab+1ab + 1.
Let Sp,qS_{p,q} be the collection of small numbers, while Tp,qT_{p,q} be the collection of big numbers. Write out Sp,qTp,qS_{p,q} \cup T_{p,q} in increasing order, and we get a sequence c1,,ca+b1c_1, \dots, c_{a+b-1} (note that clearly Sp,qTp,q={1}S_{p,q} \cap T_{p,q} = \{1\}). We claim that for each n2n \ge 2, if i,j<ni, j < n are the maximum indices such that ciSp,qc_i \in S_{p,q}, cjTp,qc_j \in T_{p,q}, then cn=ci+cjc_n = c_i + c_j, and furthermore cnSp,qc_n \in S_{p,q} if and only if cipmodq>(cjp)modqc_i p \bmod q > (-c_j p) \bmod q, in which case cnpmodq=(cipmodq)(cjpmodq)c_n p \bmod q = (c_i p \bmod q) - (-c_j p \bmod q).
We will show this by induction on nn. When n=2n=2 this is trivial. Now suppose that it holds for all indices smaller than nn. By replacing pp with p-p, we can WLOG assume that cipmodq>(cjp)modqc_i p \bmod q > (-c_j p) \bmod q.
If cn<ci+cjc_n < c_i + c_j and cnTp,qc_n \in T_{p,q}, then (cnp)modq<(cjp)modq(-c_n p) \bmod q < (-c_j p) \bmod q, showing that 0<(cncj)pmodq<(cjp)modq<cipmodq0 < (c_n - c_j) p \bmod q < (-c_j p) \bmod q < c_i p \bmod q. Since cncj<cic_n - c_j < c_i, this contradicts the fact that ciSp,qc_i \in S_{p,q}.
If cn<ci+cjc_n < c_i + c_j and cnSp,qc_n \in S_{p,q}, then we have cnci<cjc_n - c_i < c_j and 0<cncjpmodq<cipmodq0 < -c_n c_j p \bmod q < c_i p \bmod q. Let ckc_k be the largest index smaller than cjc_j that lies in Tp,qT_{p,q}. Then it is clear that (ckp)modq<cipmodq(-c_k p) \bmod q < c_i p \bmod q. If i<ji < j, then by the inductive hypothesis, we have ci+1Sp,qc_{i+1} \in S_{p,q}, which contradicts the choice of ii. Therefore i>ji > j. Now let <j\ell < j be the largest such that cSp,qc_\ell \in S_{p,q}. Then since <j<i\ell < j < i, by the inductive hypothesis we have (cjp)modq=(ckpmodq)(cpmodq)<(cipmodq)(cipmodq)=0(-c_j p) \bmod q = (-c_k p \bmod q) - (c_\ell p \bmod q) < (c_i p \bmod q) - (c_i p \bmod q) = 0. This is a contradiction.
Therefore cnci+cjc_n \ge c_i + c_j. However, note that (ci+cj)modq=(cipmodq)((cjp)modq)<cipmodq(c_i + c_j) \bmod q = (c_i p \bmod q) - ((-c_j p) \bmod q) < c_i p \bmod q, showing that ci+cjSp,qc_i + c_j \in S_{p,q} and so cn=ci+cjc_n = c_i + c_j.
Hence we can construct the sequence cnc_n as follows: we first start with a red positive integer xx and a blue positive integer yy. Each time we choose the last red number and the last blue number and add them together, and color the number red or blue. We write mm red numbers and nn blue numbers in total. The situation above is when x=y=1,m=a1,n=b1x = y = 1, m = a - 1, n = b - 1 and red numbers are members of Sp,qS_{p,q}, blue numbers are members of Tp,qT_{p,q}. Let f(m,n,x,y)f(m, n, x, y) be the minimum possible total of the last written red number and the last written blue number. Since in the original setting, the last red number ss and the last blue number tt clearly satisfies spmodq=(tp)modq=1sp \bmod q = (-tp) \bmod q = 1 and so s+t=qs + t = q, what we need to do is to give a lower bound of f(a,b,1,1)f(a, b, 1, 1). In fact, we can see that if m,n1m, n \ge 1, then
f(m,n,x,y)=min(f(m1,n,x+y,y),f(m,n1,x,x+y)) f(m, n, x, y) = \min(f(m - 1, n, x + y, y), f(m, n - 1, x, x + y))
where the first term corresponds to coloring the next number red, and the second term corresponds to coloring the next number blue. We also have that f(m,0,x,y)=x+(m+1)yf(m, 0, x, y) = x + (m + 1)y, f(0,n,x,y)=(n+1)x+yf(0, n, x, y) = (n + 1)x + y. Thus, we can induct on m+nm + n and show that f(m,n,x,y)=mnmin(x,y)+(m+1)x+(n+1)yf(m, n, x, y) = mn \min(x, y) + (m + 1)x + (n + 1)y: suppose that it holds for all smaller m+nm + n, then
f(m,n,x,y)=min((m1)ny+m(x+y)+(n+1)y,m(n1)x+(m+1)x+(n+1)(x+y))=mnmin(x,y)+(m+1)x+(n+1)y, \begin{align*} f(m, n, x, y) \\ &= \min \left( (m-1)ny + m(x+y) + (n+1)y, m(n-1)x + (m+1)x + (n+1)(x+y) \right) \\ &= mn \min(x, y) + (m+1)x + (n+1)y, \end{align*}
as desired. Thus, qf(a1,b1,1,1)=ab+1q \ge f(a-1, b-1, 1, 1) = ab + 1.

To show that it is possible that q=ab+1q = ab + 1, pick p=ap = a. Then Tp,q={1,2,,b}T_{p,q} = \{1, 2, \dots, b\} and Sp,q={1,b+1,,(a1)b+1}S_{p,q} = \{1, b+1, \dots, (a-1)b+1\}.

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 translated into English from zh; metadata (topic, difficulty) added by this project.