#P1896. Non-attacking Kings Placement
Non-attacking Kings Placement
Non-attacking Kings Placement
Given an \(N \times N\) chessboard, the task is to place \(K\) kings such that no two kings attack each other. A king can attack one square in each of the eight directions: up, down, left, right, and the four diagonals. In other words, if a king is placed at cell \((i,j)\), it can attack any cell \((i+dx, j+dy)\) for \(dx,dy \in \{-1,0,1\}\) (except when both are zero). The goal is to count the number of distinct arrangements for placing the kings.
Note: All formulas above are in LaTeX. Use appropriate precision if needed.
inputFormat
The input consists of two space-separated integers: \(N\) and \(K\), where \(N\) represents the size of the chessboard (i.e. the board is \(N \times N\)) and \(K\) is the number of kings to place.
outputFormat
Output a single integer, which is the number of valid arrangements to place \(K\) non-attacking kings on an \(N \times N\) chessboard.
sample
1 1
1