We have a $n \times m$ grid. How many ways to put $p$ points on it, so that every column and row had at least one point.

628 Views Asked by At

We have a $n \times m$ grid. How many different ways can we put $p$ coins on it, so that every coin was in a unique cell in the grid, and every column of the grid and every row had at least one coin.

Well I tried tackling it using inclusion-exclusion principle:

All of the ways of putting $p$ point on a grid: ${{n \cdot m}\choose{p}}$

Then we substract all of the wrong combinations.

Let $A$- set of all arrangments that leave some numbers of rows empty, $B$ set of all arrangments that leave some numbers of columns empty.

Then wrong combinations- $|A \cup B|=|A|+|B|-|A \cap B|$.

$|A|=\sum\limits_{k=1}^n (-1)^{k+1}{{n}\choose{k}}{{(n-k) \cdot m}\choose{p}}$ - we choose $k$ from $n$ rows that are empty and fill the rest of $(n-k)$ rows

$|B|=\sum\limits_{k=1}^m (-1)^{k+1}{{m}\choose{k}}{{n \cdot (m-k)}\choose{p}}$ - similar to above.

$|A \cap B|=\sum\limits_{k=1}^n (-1)^{k+1}{{n}\choose{k}}\sum\limits_{z=1}^m (-1)^{z+1}{{m}\choose{z}}{{n - k*m-(n-k)*z}\choose{p}}$ - first we choose how many rows we want empty, then we choose how many rows, then we count the number of way of that columns may be faulty to, and put points in the remaining places..

1

There are 1 best solutions below

2
On BEST ANSWER

A simplification: we can include-exclude over $i$ all-$0$ rows and $j$ all-$0$ columns in one go. This gives the number as $$\sum_{i=0}^n \sum_{j=0}^m (-1)^{i+j} \binom{n}{i} \binom{m}{j} \binom{(n-i)(m-j)}{p}.$$

(This formula was verified comptuationally for $n \leq 4$, $m \leq 5$ and $p \in \{1,2,\ldots,nm\}$.)