We’re preparing your current view and syncing the latest data.
You are given an n×n chessboard and an integer k. You need to determine how many ways you can place k bishops on the board such that no two bishops attack each other. Bishops attack diagonally, so no two bishops can share a diagonal. Return the number of possible arrangements.
The input contains two integers n and k, where n is the size of the chessboard and k is the number of bishops to place.
Output the number of ways to arrange k non-attacking bishops on an n×n board.
1 ≤ n ≤ 8, 0 ≤ k ≤ 2n - 2
Example 1
Input
4 4
Output
256
Explanation
There are 256 ways to place 4 bishops on a 4×4 board so that no two attack each other.