F - Solitaire Editorial /

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 1200

問題文

すぬけくんは N 枚のカードとデック(両端キュー)で遊ぶことにしました。 カードには 1,2,3...,N の数が書かれており、デックははじめ空です。

すぬけくんは 1,2,3,...,N が書かれたカードをこの順に、それぞれデックの先頭あるいは末尾に挿入します。 その後、すぬけくんはデックの先頭あるいは末尾からカードを取り出して食べる、という操作を N 回行います。

食べたカードに書かれていた数を食べた順番に並べて数列を作ることにします。このようにして作ることが可能な数列のうち、K 番目の要素が 1 であるようなものの個数を 10^{9} + 7 で割った余りを求めなさい。

制約

  • 1 ≦ K ≦ N ≦ 2{,}000

入力

入力は以下の形式で標準入力から与えられる。

N K

出力

答えを出力せよ。


入力例 1

2 1

出力例 1

1

条件を満たす並びは 1,21 通りです。例えば以下のようにして、この並びを構成することが可能です。

  • 1,2 のどちらもカードの山の一番下に挿入する
  • カードの山の一番上からカードを取り出して食べることを 2 回行う

入力例 2

17 2

出力例 2

262144

入力例 3

2000 1000

出力例 3

674286644

Score : 1200 points

Problem Statement

Snuke has decided to play with N cards and a deque (that is, a double-ended queue). Each card shows an integer from 1 through N, and the deque is initially empty.

Snuke will insert the cards at the beginning or the end of the deque one at a time, in order from 1 to N. Then, he will perform the following action N times: take out the card from the beginning or the end of the deque and eat it.

Afterwards, we will construct an integer sequence by arranging the integers written on the eaten cards, in the order they are eaten. Among the sequences that can be obtained in this way, find the number of the sequences such that the K-th element is 1. Print the answer modulo 10^{9} + 7.

Constraints

  • 1 ≦ K ≦ N ≦ 2{,}000

Input

The input is given from Standard Input in the following format:

N K

Output

Print the answer modulo 10^{9} + 7.


Sample Input 1

2 1

Sample Output 1

1

There is one sequence satisfying the condition: 1,2. One possible way to obtain this sequence is the following:

  • Insert both cards, 1 and 2, at the end of the deque.
  • Eat the card at the beginning of the deque twice.

Sample Input 2

17 2

Sample Output 2

262144

Sample Input 3

2000 1000

Sample Output 3

674286644