I though you were asking about solution not the formula
I.e. how do you know given formula always works?
The key here is to rephrase the problem from obscure form given into something mathematical.
You write each solution as a fixed sequence of slots (number of columns/rows) filled up with numbers you get from splitting up number of rows/columns. Then count.
And yes, OG is right. It is much faster to do some counting with elimination because the numbers here are small.