Problem 7:
Queens and Rooks
The well-known n-queens problem attempts to place n queens
on an n x n 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 and (2) the number of queens. 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
To hand in the program, use the command:
handin acmjudge prog7