Dispersed parentheses

시간 제한1초메모리 제한1024 MB

요약
기호 0, (, )로 이루어진 길이 n 문자열 가운데 깊이가 정확히 k인 분산 괄호 수열의 개수를 1e9+9로 나눈 나머지를 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, 조합론, 재귀
정답자
아직 제출이 없습니다

문제

The sequence of calculations in arithmetic expressions is usually set by a certain arrangement of parentheses. For example, (3⋅(2+1))⋅(4−5)(3 \cdot (2+1)) \cdot (4-5). After deleting all the elements from the expression except parentheses remaining symbols form a parentheses sequence (())()(())(). Let’s assume that adding character <<00>> does not corrupt the sequence. Let’s call such sequence a disperse parentheses sequence. Also this can be defined as follows:

  • An empty line is a disperse parentheses sequence.
  • If SS and TT --- disperse parentheses sequences, then lines 0S,S0,(S)0S, S0, (S) and STST are also disperse parentheses sequences.

The depth of disperse parentheses sequence is the maximum difference between the number of opening and closing parentheses in the sequence prefix. (The prefix of line SS is the line, which can be obtained from SS by deleting symbols from the tail of the line. For example, the prefixes of line «ABCABABCAB» are lines <<>>, <<AA>>, <<ABAB>>, <<ABCABC>>, <<ABCAABCA>> and <<ABCABABCAB>>). Thus, the depth of the sequence «(0)(0())0(0)(0())0» equals two (prefix «(0)(0((0)(0(» contains three openinig and one closing parentheses).

Calculate the number of possible disperse parentheses sequences nn symbols long, that have a depth kk.

입력

Single line contains space-separated integers nn and kk (1≤n≤3001 \le n \le 300, 0≤k≤n0 \le k \le n).

출력

Output the number of possible disperse parentheses sequences nn symbols long, that have a depth kk modulo (109+910^9+9).

예제3

  1. 예제 1

    입력
    3 0
    
    예상 출력
    1
    
  2. 예제 2

    입력
    3 1
    
    예상 출력
    3
    
  3. 예제 3

    입력
    3 2
    
    예상 출력
    0