Loading web-font TeX/Math/Italic

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.

Contributed by Project Gauss

Solved by 13 users

Log in to submit answers.

Is something wrong?

Maintaining a collection of high quality questions is our top priority. If, however, you do find an error, report the problem and we'll make sure it is reviewed soon.