time limit per test: 0.75 sec. memory limit per test: 65536 KB
input: standard output: standard
Well, you might have heard about a curious boy Petya who likes to learn the number of ways one can put k identical chess pieces on a chessboard of size n× n so that no two of them are in the attacking positions. He have solved the problems for bishops, rooks and kings. Recently he has met Farmer John and told him about that.
Impressed FJ has decided to teach his cows to play chess. The first question Bessie asked on the first lesson was: "What about the number of ways one can put k queens on a chessboard of size n × n, so that no two of them are in the attacking positions?"
The queen can move diagonally, horizonatally and vertically, thus combining the properties of a bishop and a rook. Two queens are in the attacking positions if they are on the path of each other.
Input
The input file contains two integers n (1 ≤ n ≤ 10) and k (0 ≤ k ≤ n2).
Output
Print a line containing the total number of ways one can put the given number of queens on a chessboard of the given size so that no two of them are in attacking positions.
Sample test(s)
Input
Test #1
3 2
Test #2
4 4
Output
Test #1
8
Test #2
2
Author:
Andrew Stankevich
Resource:
Little Chess Pieces Series, SPb IFMO 2003-2004 Authumn Training Sessions