How many ways are there to place $2$ identical kings on an $8\times 8$ chessboard so that the kings are not in adjacent squares? This problem needs also to be extended to $n*m$ chessboard. I tried to think like this:
First I choose a place for the first king in $64$ ways. Then I have a  choice $64-5 = 59$ squares for the second king . But this solution is not right because this is not the case if I place the first king in the sidemost layers of squares. Then I have $64-4 = 60$ squares for the other king. How can I solve this problem?
 A: The first King could be on a corner square($4$ ways), leaving $60$ other squares for the next King.
The first King could be on a edge square($24$ ways), leaving $58$ other squares for the next King.
The first King could be on a central square($36$ ways), leaving $55$ other squares for the next King.
This will double count the configurations, so we have $(4 \times 60 + 24 \times 58 + 36 \times 55)/2 =\color{red}{1806}$.
A: You have ${64\choose 2} = 32\cdot 63=2016$ ways to put $2$ kings on board without restriction (since they are the same). Now we have $7\cdot 8\cdot 2+7\cdot 7\cdot 2 =210$ adjacent pairs of squares (I count that pairs directly, in one row you have $7$ adjacent pairs and we have 8 rows, the same holds for columns, and then I count diagonally neighbors).
So we can put them on $2016-210 = 1806$ ways they are not together.   
A: If you want "non-attacking" placements, in which "adjacent" includes diagonally adjacent, then the answer is
$$4(64-4)+4\cdot6(64-6)+6\cdot6(64-9)\over2$$
That is, the "first" king goes either in one of $4$ corners and the "second" king avoids it and the $3$ adjacent squares, or it goes in one of the $6$ other squares along one of the $4$ sides, with the second king avoiding it and the $5$ adjacent squares, or it goes in one of the $6\cdot6$ interior squares and the second king avoids it and the $8$ surrounding squares. That gives the numerator. The denominator comes because you don't want to distinguish "first" from "second."
If "adjacent" is restricted to horizontal and vertical adjacency, then the answer is
$$4(64-3)+4\cdot6(64-4)+6\cdot6(64-5)\over2$$
by the same reasoning.
A: We will solve the problem by cases.
1) We put the first king on the corner square. Then there are 4 ways to do it, and for the second king we have 64-3=61. Then there are $4\cdot61=244$ ways to do it.
2) We put the first king on the edge square. Then for the first king $6+6+6+6=24$ ways to do it, then for the second it is $64-4=60$ ways to do it. So it is $24\cdot60=1440$ ways to do it.
3)We put king neither in the corner, nor on the edge. So we have $6\cdot6=36$ ways for the first king and for the second $64-5=59$ ways to do it. So it is $36\cdot59=2124$ ways.
So together it is $(2124+1440+244)/2=1904$ ways to do it.  We are dividing by 2 because we are double-counting when we analyze cases, because the order of putting kings doesn't matter.
And now, I think, it is easy to generalise it for $n×m$ case.
