Maths Olympiad Prep

Library / Mediterranean Mathematics Competition /2 of 4

Mediterranean Mathematics Competition

Combinatorics Difficulty 6.3 National Olympiad Prove it North Macedonia

Let pp be a positive integer, p>1p > 1. Find the number of m×nm \times n matrices with entries in the set {1,2,3,...,p}\{1,2,3,..., p\} and such that the sum of elements on each row and each column is not divisible by pp.

Solution

Denote by XX the set of all matrices with entries in the set {1,2,3,...,p}\{1,2,3,..., p\} and let AiA_i, respectively BjB_j, the set of matrices in which the sum of elements in the row ii, respectively on the column jj, be divisible by pp. Then we have to obtain the cardinality NN of the set
X∖((⋃i=1mAi)∪(⋃j=1nBj)). X \setminus \left( \left( \bigcup_{i=1}^{m} A_i \right) \cup \left( \bigcup_{j=1}^{n} B_j \right) \right).
For this we apply the inclusion-exclusion principle. Then
N=pmn+∑i=0m∑j=0n(−1)i+j∑k1<k2<⋯<kil1<l2<⋯<lj∣Ak1∩Ak2∩⋯∩Aki∩Bl1∩Bl2∩⋯∩Blj∣(i) N = p^{mn} + \sum_{i=0}^{m} \sum_{j=0}^{n} (-1)^{i+j} \sum_{\substack{k_1 < k_2 < \dots < k_i \\ l_1 < l_2 < \dots < l_j}} |A_{k_1} \cap A_{k_2} \cap \dots \cap A_{k_i} \cap B_{l_1} \cap B_{l_2} \cap \dots \cap B_{l_j}| \quad (i)
the sum being taken for all i,ji, j with i+j≠0i + j \neq 0.
But we have
∣Ak1∩Ak2∩⋯∩Aki∩Bl1∩Bl2∩⋯∩Blj∣=∣A1∩A2∩⋯∩Ai∩B1∩B2∩⋯∩Bj∣(ii)|A_{k_1} \cap A_{k_2} \cap \dots \cap A_{k_i} \cap B_{l_1} \cap B_{l_2} \cap \dots \cap B_{l_j}| = |A_1 \cap A_2 \cap \dots \cap A_i \cap B_1 \cap B_2 \cap \dots \cap B_j| \quad (ii)
and moreover
pmn=(−1)0+0(m0)(n0)pmn−0−0. p^{mn} = (-1)^{0+0} \binom{m}{0} \binom{n}{0} p^{mn-0-0}.
For all i,ji, j participating in the summation we have
∣A1∩A2∩⋯∩Ai∩B1∩B2∩⋯∩Bj∣={pmn−i−j,if i≠m or j≠npmn−m−n−1,if i=m and j=n |A_1 \cap A_2 \cap \dots \cap A_i \cap B_1 \cap B_2 \cap \dots \cap B_j| = \begin{cases} p^{mn-i-j}, & \text{if } i \neq m \text{ or } j \neq n \\ p^{mn-m-n-1}, & \text{if } i = m \text{ and } j = n \end{cases}
So,
N=∑i=0m∑j=0m∑i+j≠m+n(−1)i+j(mi)(nj)pmn−i−j+(−1)m+n(mm)(nn)pmn−m−n+1==∑i=0m∑j=0m(−1)i+j(mi)(nj)pmn−i−j−(−1)m+n(mm)(nn)pmn−m−n++(−1)m+n(mm)(nn)pmn−m−n+1= \begin{align*} N &= \sum_{i=0}^{m} \sum_{j=0}^{m} \sum_{i+j \neq m+n} (-1)^{i+j} \binom{m}{i} \binom{n}{j} p^{mn-i-j} + (-1)^{m+n} \binom{m}{m} \binom{n}{n} p^{mn-m-n+1} = \\ &= \sum_{i=0}^{m} \sum_{j=0}^{m} (-1)^{i+j} \binom{m}{i} \binom{n}{j} p^{mn-i-j} - (-1)^{m+n} \binom{m}{m} \binom{n}{n} p^{mn-m-n} + \\ & \qquad + (-1)^{m+n} \binom{m}{m} \binom{n}{n} p^{mn-m-n+1} = \end{align*}
---

=∑s=0m+n(−1)spmn−s∑i+j=s(mi)(nj)+(−1)m+n(mm)(nn)pmn−m−n(p−1)==pmn∑s=0m+n(−1p)s(m+ns)+(−1)m+npmn−m−n(p−1)==pmn((−1p)m+n+(−1)m+n(mm)(nn)pmn−m−n(p−1))==pmn−m−n((p−1)m+n+(−1)m+n(p−1))\begin{align*} &= \sum_{s=0}^{m+n} (-1)^s p^{mn-s} \sum_{i+j=s} \binom{m}{i} \binom{n}{j} + (-1)^{m+n} \binom{m}{m} \binom{n}{n} p^{mn-m-n} (p-1) = \\ &= p^{mn} \sum_{s=0}^{m+n} \left(\frac{-1}{p}\right)^s \binom{m+n}{s} + (-1)^{m+n} p^{mn-m-n} (p-1) = \\ &= p^{mn} \left( \left(-\frac{1}{p}\right)^{m+n} + (-1)^{m+n} \binom{m}{m} \binom{n}{n} p^{mn-m-n} (p-1) \right) = \\ &= p^{mn-m-n} \left( (p-1)^{m+n} + (-1)^{m+n} (p-1) \right) \end{align*}

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.