#P12415. 「YLLOI-R1-T4」枫

    ID: 11798 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划 DP洛谷原创O2优化组合数学洛谷月赛

「YLLOI-R1-T4」枫

Description

There is a grid with nn rows and mm columns. You need to construct a tree on this grid such that:

  • Each node of the tree corresponds to a cell in the grid.
  • Each cell can correspond to at most one node.
  • For any node in the tree, the row of its corresponding cell is strictly less than the row of any of its children. (Rows are numbered from top to bottom.)

The nodes are unlabelled; all nodes are identical.

Two trees are considered identical if they satisfy all the following conditions:

  • They contain the same number of nodes.
  • The set of grid cells corresponding to the nodes are the same. Formally, if the set of cells used in the two trees are S1S_1 and S2S_2, then S1=S2S_1 = S_2.
  • The parent–child relationships are exactly the same. Formally, for every cell xS1,S2x\in S_1,S_2, let S1S_1' and S2S_2' be the sets of cells corresponding to the children of xx in the two trees,then S1=S2S_1'=S_2'.

Determine how many distinct trees can be constructed. Output the answer modulo 109+710^9 + 7.

Input Format

A single line containing two positive integers nn and mm.

Output Format

A single integer — the number of distinct trees modulo 109+710^9 + 7.

2 2
10
3 2
86

Hint

Explanation

Sample 1:

The figure below shows all distinct trees:

Sample 2:

  • There are 66 distinct trees with 11 node.
  • There are 1212 distinct trees with 22 nodes.
  • There are 2222 distinct trees with 33 nodes.
  • There are 2828 distinct trees with 44 nodes.
  • There are 1818 distinct trees with 55 nodes.
  • There are 00 distinct trees with 66 nodes.

So in total, there are 6+12+22+28+18+0=866 + 12 + 22 + 28 + 18 + 0 = 86 distinct trees.

Constraints

This problem uses subtask scoring.

  • Subtask 1 (10 pts): n=2n = 2.
  • Subtask 2 (10 pts): m=1m = 1.
  • Subtask 3 (10 pts): n,m3n, m \le 3.
  • Subtask 4 (20 pts): n,m20n, m \le 20.
  • Subtask 5 (20 pts): n,m50n, m \le 50.
  • Subtask 6 (30 pts): No additional constraints.

For all data: 1n,m801 \le n, m \le 80.