题目描述
Let X be the set of correctly built parenthesis expressions. The elements of X are strings consisting only of the characters “('' and “)'', defined as follows:
The empty string belongs to X.
If A belongs to X, then (A) belongs to X.
If both A and B belong to X, then the concatenation AB belongs to X.
For example, the strings ()(())() and (()(())) are correctly built parenthesis expressions, and therefore belong to the set X. The expressions (()))(() and ())(() are not correctly built parenthesis expressions and are thus not in X.
The length of a correctly built parenthesis expression E is the number of single parenthesis (characters) in E. The depth D(E) of E is defined as follows:
For example, ()(())() has length 8 and depth 2. Write a program which reads in n and d and computes the number of correctly built parenthesis expressions of length n and depth d.
输入
The input consists of pairs of integers n and d, with at most one pair per line and 2<=n<=300, 1d150. The input may contain empty lines, which you don't need to consider.
输出
For every pair of integers in the input, output a single integer on one line – the number of correctly built parenthesis expressions of length n and depth d.
样例输入
6 2
300 150
样例输出
3
1
Note: The three correctly built parenthesis expressions of length 6 and depth 2 are (())(), ()(()), and (()()).
参考代码
暂无
解析
暂无