I know that given a R×C contingency table observed on N subjects, the maximum value of $\chi^2$ statistics is N⋅[min(R,C)−1]. But, this value is independent of given margins (namely, row totals and column totals. Is there a closed formula or an easy way for computing such a maximum?
For example: in a 2×2 contingency table with margins [50,50][50,50] and [10,90][10,90], it is easy to observe that there the table
0 50
10 40
is the only one having the highest χ2 (11.1111 and not 100) among all the tables with the same marginals. Are there papers or algorithms for searching it in a feasible time also for a generic R×C table given its marginals?