Fill matrix with elements from $\mathbb{Z}/(n)$ such that sums of rows and columns have specific values

84 Views Asked by At

Given $n,p,q$ integers greater than $0$, and $a,b \in \mathbb{Z}/(n)$, what is the number of $p*q$ matrices with elements in $\mathbb{Z}/(n)$ such that the sum of entries in any row is equal to $a$ and the sum of elements in any column is equal to $b$?

The only thing i was able to get is that we must have $pa \equiv qb $ (mod $n)$ in order for such a matrix to exist, but I couldn't get anything else.

1

There are 1 best solutions below

0
On BEST ANSWER

The upper-left $(p-1)\times (q-1)$ block can be filled with arbitrary values. This then forces the bottom row and the rightmost column, and the bottom-right corner number can be filled (consistent with both the column sum and row sum requirements) iff $pa = qb \pmod n$.

So the number of such matrices is $n^{(p-1)(q-1)}$.