Montmort Number
By Kay Akashi
Time: 1000 ms
Memory: 256000 kB
The code judging system is only available during contests. Check out the
github repo for test cases and solutions.
Problem Statement
The number of possible permutations which satisfy the following condition is called the Montmort number:
The possible number of P=(p1,p2,...,pN) ( P is a permutation of (1,2,...,N) ) such that i=pi for ∀i∈(1,2,3,…,N).
The Montmort number for the array of length N is given as:
aN=N!∑k=2Nk!(−1)k
Given the integer N, output aN, the Montmort number of array of length N.
Constraints
2≤N≤15
Input
The input consists of a single integer, N.
Output
Output the Montmort number for N.
Examples