A Rook Problem

View as PDF

Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

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

A rook can only move horizontally and vertically from its current position and two rooks are in an attacking position if one is on the path of the 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 rooks on an N \times N chessboard such that no rooks are in an attacking position.

Sample Input

4 4

Sample Output

24

Comments


  • -5
    Dmoj  commented on Dec. 9, 2019, 5:48 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.