P28345 [洛谷] [SCOI2003] Strict N-ary Tree
提高+
题目描述

Problem Description

If a tree has exactly $n$ children for all non-leaf nodes, we call it a strict $n$-ary tree. If the deepest nodes in the tree have a depth of $d$ (with the root having a depth of 0), we call it a strict $n$-ary tree of depth $d$. For example, there are three strict 2-ary trees of depth 2, as shown in the following figure:

Given $n$ and $d$, write a program to count the number of strict $n$-ary trees of depth $d$.

Input Format

The input consists of two integers $n$ and $d$ where $0 < n \le 32$ and $0 \le d \le 16$. The input data ensures that you do not need to consider trees with more than $1024$ nodes at any level (i.e., $\le 1024$). Hint: The answer is guaranteed to be a number with no more than 200 decimal digits.

Output Format

The output should contain a single number, which is the count of strict $n$-ary trees of depth $d$.

Sample Input and Output

Sample Input #1

2 2

Sample Output #1

3

Sample Input #2

2 3

Sample Output #2

21

Sample Input #3

3 5

Sample Output #3

58871587162270592645034001
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 2
样例输出
3