CF BUDDY
← Problems·

1288C · Two Arrays

1600 · combinatorics, dp

Problem: You are given two integers nn and mm. Calculate the number of pairs of arrays (a,b)(a, b) such that:

  • the length of both arrays is equal to mm;
  • each element of each array is an integer between 11 and nn (inclusive);
  • aibia_i \le b_i for any index ii from 11 to mm;
  • array aa is sorted in non-descending order;
  • array bb is sorted in non-ascending order.

As the result can be very large, you should print it modulo 109+710^9+7.

Input Format: The only line contains two integers nn and mm (1n10001 \le n \le 1000, 1m101 \le m \le 10).

Output Format: Print one integer – the number of arrays aa and bb satisfying the conditions described above modulo 109+710^9+7.

Note: In the first test there are 55 suitable arrays:

  • a=[1,1],b=[2,2]a = [1, 1], b = [2, 2];
  • a=[1,2],b=[2,2]a = [1, 2], b = [2, 2];
  • a=[2,2],b=[2,2]a = [2, 2], b = [2, 2];
  • a=[1,1],b=[2,1]a = [1, 1], b = [2, 1];
  • a=[1,1],b=[1,1]a = [1, 1], b = [1, 1].

Sample Cases

Case 1

Input

2 2

Output

5

Case 2

Input

10 1

Output

55

Case 3

Input

723 9

Output

157557417

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback