Chess Knights
Background:
Well, I haven't given very many chess problems, so here's one.
In chess, a knight (the horsehead piece) moves quite differently
than any other piece. It moves in an L-type shape. That
is, it can move two squares in one direction, then one square
in the perpendicular direction (knights can not move
diagonally). As an example, consider this:
| . | . | . | . | . | . | . | . |
| . | . | . | . | . | . | . | . |
| . | . | . | * | . | * | . | . |
| . | . | * | . | . | . | * | . |
| . | . | . | . | K | . | . | . |
| . | . | * | . | . | . | * | . |
| . | . | . | * | . | * | . | . |
| . | . | . | . | . | . | . | . |
The knight is in the square marked by a `K'. The `*' around
it are the possible positions the knight can move on the next turn.
The `.' are empty squares.
If you place two knights on the board, things get a little more
complicated. We say that a knight can not be taken if there is
not knight that can land on it's square on the next turn. This condition
has to hold reguardless of what order the knights move (ie, the
knights can't `move' out of the way).
Input:
Each line of input will have two integers, M, N, separated
by exactly one space. The chessboard has size M x M.
We're interested in placing N knights on the board such
that no knight can take any other knight. The number of knights
will be in the range 1 to 36 (inclusive). M will
be in the range 1 to 6 (inclusive).
Output:
For each line of input, your program should print out the number
of ways that we can place N knights on an M x M
chessboard. The answer will always fit in an unsigned, 32 bit
integer.
Sample Input:
2 2
3 2
6 4
6 15
Sample Output:
6
28
26133
2560