A King Problem

View as PDF

Submit solution

Points: 12
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

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

Recall that a king can move to any adjacent cell (there are up to eight such cells). Thus, two kings are in the attacking position if they are located on the adjacent cells.

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 kings on an N \times N chessboard such that no kings are in an attacking position.

Sample Input 1

3 2

Sample Output 1

16

Sample Input 2

4 4

Sample Output 2

79

Comments

There are no comments at the moment.