14764 - Ceobe IQ Test   

Description

Ceobe is a curious girl, but it is really hard to determine the IQ of this cute Perro girl, whether she is a hidden genious or just a normal glutton is up to you.

So the task Doctor gave her is to count how many ways can she put $M$ queens inside a $N \times N$ chessboard so that no two queens attack each other. In the game of chess, the queen can attack freely diagonally, horizontally and vertically.

Ofcourse Ceobe will struggle with this complex of a question, so Doctor gave her some hint:

  • Help
  • If $M=0$ and  $N=3$, only 1 board is possible:
  • If $M=1$ and $N=3$, there will be 9 possible boards:
  • If $M=2$ and $N=3$, there will be 8 possible boards:
  • If $M=3$ and $N=3$, there're no board that can satisfy.

Image credit: Arknights Official youtube channel

Input

The input will consist of 1 line containing 2 numbers:

  • The first number $M$ will be the number of queens to put in.
  • The second number $N$ is the size of the chessboard.

Constraints

  • Testcase 1-4: $M = N$
  • Testcase 5-6: $M \neq N$

Output

Count how many ways to put $M$ queens inside a $N \times N$ chessboard.

Sample Input  Download

Sample Output  Download

Tags




Discuss