A Queen Problem

View as PDF

Submit solution

Points: 7
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Yi is an avid chess player. He would like to know how many ways it is possible to place K queens on an N \times N chessboard such that no queen is in an attacking position.

The queen can move diagonally, horizontally and vertically, thus combining the properties of a bishop and a rook. Two queens are in the attacking positions if they are on the path of each other.

Input Specification

The first line will contain two integers N, K\ (1 \le N \le 10, 1 \le K \le N^2).

Output Specification

The number of ways to place K queens on an N \times N chessboard such that no queens are in an attacking position.

Sample Input 1

3 2

Sample Output 1

8

Sample Input 2

4 4

Sample Output 2

2

Comments

There are no comments at the moment.