CPguessr

One Codeforces problem. Guess how hard it is.

Daily #78 · next problem in23h 29m

Positions in Permutations

2s · 256 MB

Permutation pp is an ordered set of integers p1,p2,...,pnp_{1}, p_{2}, ..., p_{n} , consisting of nn distinct positive integers, each of them doesn't exceed nn . We'll denote the ii -th element of permutation pp as pip_{i} . We'll call number nn the size or the length of permutation p1,p2,...,pnp_{1}, p_{2}, ..., p_{n} .

We'll call position ii ( 1≤i≤n1 ≤ i ≤ n ) in permutation p1,p2,...,pnp_{1}, p_{2}, ..., p_{n} good, if ∣p[i]−i∣=1|p[i] - i| = 1 . Count the number of permutations of size nn with exactly kk good positions. Print the answer modulo 10000000071000000007 ( 109+710^{9} + 7 ).

Input

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

Output

Print the number of permutations of length nn with exactly kk good positions modulo 10000000071000000007 ( 109+710^{9} + 7 ).

Note

The only permutation of size 1 has 0 good positions.

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

Permutations of size 3:

  • (1,2,3)(1, 2, 3) — 0 positions

— 2 positions

— 2 positions

— 2 positions

— 2 positions

  • (3,2,1)(3, 2, 1) — 0 positions
Input
1 0
Output
1
Input
2 1
Output
0
Input
3 2
Output
4

How hard is this problem?

Guessing pays XP and coins, so it needs an account. Read the problem, then sign in to lock in a rating.

How scoring works

Type any whole number. The answer is clist's rating, a whole-integer estimate from the performance of everyone who attempted the problem, so it lands on values like 759 or 1437 and is not capped at Codeforces' 3500. Within 50 counts as exact and pays in full; reward falls off exponentially from there, so a couple of hundred out still pays well and a guess several bands away is worth close to nothing. Playing always pays something.

The contest, problem index and tags stay hidden until you guess: a Div. 2 A is rated 800 far more often than not, so the index alone would hand you the answer. Problems are drawn from the 8,714 rated Codeforces problems with at least a thousand solvers, so the rating has settled. Each day draws one rating band at random, so every difficulty comes up equally often and yesterday's answer says nothing about today's.

One problem per player per day, scored on your first guess.