Skip to main content
OlympiadHQ

Browse · MathNet

Print

Mediterranean Mathematics Competition

North Macedonia counting and probability

Problem

Let be a positive integer, . Find the number of matrices with entries in the set and such that the sum of elements on each row and each column is not divisible by .
Solution
Denote by the set of all matrices with entries in the set and let , respectively , the set of matrices in which the sum of elements in the row , respectively on the column , be divisible by . Then we have to obtain the cardinality of the set For this we apply the inclusion-exclusion principle. Then the sum being taken for all with . But we have and moreover For all participating in the summation we have So, ---

$$
Final answer
p^{mn-m-n} ((p-1)^{m+n} + (-1)^{m+n} (p-1))

Techniques

Inclusion-exclusionCounting two ways