HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


The N Queens Problem

Section problems

• Wonder primes
• Arithmetic Operators
• Profits
• Istanbul
• Buying hay
• Sum until 0
• Sum less than N
• Sum of N numbers
• The N Queens Problem
• Subsets
• Maximum Sum 2
• Gifts of Santa Claus
• Rectangles on a plane
• Permutations
• Reverse permutation
• Nameplates
• Adjacency matrix to edges list

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 10000/10000/10000/10000 ms. Memory limit 65000/65000/65000/65000 Kb.

Problem description

The goal of the n-queens problem is to position n queens on an nxn chessboard so that no two queens threaten each other. That is, no two queens may be in the same row, column, or diagonal.

Make a program to calculate number of the solution of n-queens problem.

Input

A single integer N (1 <= N <= 14) that is the size of the board.

Output

A single integer denotes the number of different solutions.

Example

stdin stdout

4

2

Для отправки решений необходимо выполнить вход.

www.contester.ru