Problem 7:
Queens and Rooks
The well-known n-queens problem attempts to place n queens
on an nxn chess board so that the queens cannot attack each-other.
For this problem, you will solve a variant of this problem in
which some number of the queens are replaced by rooks.
Your program must take two integer inputs (1) the size of the
board (n) and (2) the number of queens (q). The number of rooks will
then be n-q. For example, one solution
to the 4x4 board with 2 queens is given by:
. Q . .
. . . R
Q . . .
. . R .
Your objective is to count the number of queen-rook solutions for
a given board size and number of queens. Here are some sample
values:
n queens solutions
4 4 2
5 4 50
5 0 120
8 6 3464
handin acmjudge prog7