【数据范围】
对于30%的数据,保证1<=m<=n<=1000
对于100%的数据,保证1<=m<=n<=1000000
正解:组合数学。
裸卡特兰数。
1 #include <bits/stdc++.h> 2 #define il inline 3 #define RG register 4 #define ll long long 5 #define rhl (20100403) 6 #define N (2000010) 7 8 using namespace std; 9 10 int inv[N],fac[N],ifac[N],n,m; 11 12 il int C(RG int n,RG int m){ 13 return 1LL*fac[n]*ifac[m]%rhl*ifac[n-m]%rhl; 14 } 15 16 int main(){ 17 #ifndef ONLINE_JUDGE 18 freopen("string.in","r",stdin); 19 freopen("string.out","w",stdout); 20 #endif 21 cin>>n>>m,fac[0]=ifac[0]=fac[1]=ifac[1]=inv[1]=1; 22 for (RG int i=2;i<=n+m;++i){ 23 inv[i]=1LL*(rhl-rhl/i)*inv[rhl%i]%rhl; 24 fac[i]=1LL*fac[i-1]*i%rhl; 25 ifac[i]=1LL*ifac[i-1]*inv[i]%rhl; 26 } 27 printf("%d\n",(C(n+m,n)-C(n+m,n+1)+rhl)%rhl); return 0; 28 }