Problem #173
Permutation mania
Permutation p is an ordered set of integers p1,p2,...,pn consisting of n distinct positive integers, each of them doesn’t exceed n. We will denote the i^{th} element of permutation p as pi. We will call number n the size or the length of permutation p1,p2,...,pn.
We will call position i (1 ≤ i ≤ n) in permutation p1,p2,...,pn good, if |p[i]-i|=1.
Your task is to count the number of permutations of size n with exactly k good positions.
Give the answer for n=1000 and k=700 modulo 1000000007.
Example :- for n=3 and k=2 answer will be 4.
(1,3,2), (3,1,2), (2,1,3), (2,3,1) all have exactly 2 good position.