Codeforces Round 175 (Div. 2)
E
Positions in Permutations
Codeforces
2600
原题
← D→
翻译中…

Permutation $*p*$ is an ordered set of integers $*p*_{1},  *p*_{2},  ...,  *p*_{*n*}$, consisting of $*n*$ distinct positive integers, each of them doesn't exceed $*n*$. We'll denote the $*i*$-th element of permutation $*p*$ as $*p*_{*i*}$. We'll call number $*n*$ the size or the length of permutation $*p*_{1},  *p*_{2},  ...,  *p*_{*n*}$.

翻译中…

We'll call position $*i*$ ($1 ≤ *i* ≤ *n*$) in permutation $*p*_{1}, *p*_{2}, ..., *p*_{*n*}$ good, if $|*p*[*i*] - *i*| = 1$. Count the number of permutations of size $*n*$ with exactly $*k*$ good positions. Print the answer modulo $1000000007$ ($10^{9} + 7$).

翻译中…

Input

翻译中…

The single line contains two space-separated integers $*n*$ and $*k*$ ($1 ≤ *n* ≤ 1000, 0 ≤ *k* ≤ *n*$).

翻译中…

Output

翻译中…

Print the number of permutations of length $*n*$ with exactly $*k*$ good positions modulo $1000000007$ ($10^{9} + 7$).

翻译中…

Note

翻译中…

The only permutation of size 1 has 0 good positions.

翻译中…

Permutation $(1, 2)$ has 0 good positions, and permutation $(2, 1)$ has 2 positions.

翻译中…

Permutations of size 3:

翻译中…
  1. $(1, 2, 3)$ — 0 positions
  2. image — 2 positions
  3. image — 2 positions
  4. image — 2 positions
  5. image — 2 positions
  6. $(3, 2, 1)$ — 0 positions
翻译中…

样例

Input #1
1 0
Output #1
1
InputCopy OutputCopy
Input #2
2 1
Output #2
0
InputCopy OutputCopy
Input #3
3 2
Output #3
4
InputCopy OutputCopy
Input #4
4 1
Output #4
6
InputCopy OutputCopy
Input #5
7 4
Output #5
328
InputCopy OutputCopy
题目信息
题号
285E
时间限制
2 s
内存限制
256 MB
标签
组合数学
动态规划
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。