链接:https://codeforces.com/contest/1288/problem/C
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);
- ai≤biai≤bi 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+7109+7.
Input
The only line contains two integers nn and mm (1≤n≤10001≤n≤1000, 1≤m≤101≤m≤10).
Output
Print one integer – the number of arrays aa and bb satisfying the conditions described above modulo 109+7109+7.
Examples
input
Copy
2 2
output
Copy
5
input
Copy
10 1
output
Copy
55
input
Copy
723 9
output
Copy
157557417
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].
代码:
#include<bits/stdc++.h>
using namespace std;
long long n,m,t,k,x,d,max1=0,a,b,c,mod=1e9+7;
long long dp[2005][2005];
main()
{
cin>>n>>m;
dp[0][0]=1;
for(int i=1;i<=2000;i++)
{
for(int j=0;j<=i;j++)
{
if(j>0)
dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
if(j<i)
dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
}
}
cout<<dp[n+2*m-1][2*m];
}