[Math] Is is possible to obtain exactly 16 black cells

combinatorics

We are given an $18*18$ table, all of whose cells may be black or white. Initially all the cells are colored white. We may perform the following operation:
Choose one column or one row and change the colour of all cells in this column or row. Is it possible by repeating the operation to obtain a table with exactly $16$ black cells?

I know that this question is based on invariant principle but I am not getting the invariant.

Best Answer

First notice that the order in which we perform the row/column operations doesn't matter and that using two times the same column/row does nothing. Now suppose we can make $16$ black cells using $r$ row-moves and $c$ column-moves. Imagine to color the columns and rows we used, every coloured cell is now black, except the cells coloured 'two times' that are white. The total number of coloured cells is $$18(r+c)-rc.$$ The number of cells coloured two times are $rc$. So the total number of black cells are $$18(r+c)-2rc.$$ Now we have to solve (for $0\le r,c\le18$) $$18(r+c)-2rc=16$$ that can be rewritten as $$r=9-\frac{73}{9-c}.$$ Since $r$ must be a integer, we have that $(9-c) \mid 73$, the only possibility is $c=8$, but we would have $r<0$. Hence there are no solutions.

EDIT: As pointed out by @filipos we must consider also the case $c=10$, which gives $r>18$ and so it has to be discarded.