# Placing two queens on an $n \times m$ chessboard

I want to find the number of ways in which two queens can be placed on a chessboard so that they can attack each other. two queens can attack each other on a row, a column or on same diagonal just likes the moves of a queen.

I assume the queens are indistinguishable (say, both white). Wlog. $n\le m$. Then there are $n\cdot{m\choose 2}$ ways with horizontal attacks; $m\cdot {n\choose 2}$ ways with vertical attack; $(m-n)\cdot {n\choose 2}+2\sum_{k=2}^{n-1}{k\choose 2}$ ways with "falling" diagonal attack and the same number with "rising" diagonal. Use the well-known formulas for sums of quadratic sequences to get an explcit expression for $\sum_{k=2}^{n-1}{k\choose 2}$ and add all up.