Cattleya number
definition
Cattleya number is a mathematical combination is found in a variety of problems in counting the number of columns.
Given n 0, n-1, 2n are arranged in sequence satisfy: any prefix number 0 or greater number of species of number 1 of the arrangement, is the number of Cattleya.
Several of its front (starting from zero): the 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796
Recurrence formula
Setting h (n) is n + 1, the number of items of catalan, so that h (0) = 1, h (1) = 1
-
h(n)= h(0) * h(n-1)+h(1) *h(n-2) + … + h(n-1) *h(0) (n>=2)
eg : h(3)=h(0) *h(2)+h(1) *h(1)+h(2) *h(0)=1 *2+1 *1+2 *1=5
-
h(n)=h(n-1) * (4 * n-2) / (n+1);
Solution of recursion relations:
H (n-) = C (2N, n-) / (n-+. 1) (n-= 0,1,2, ...)
Alternative Solutions of recursion relations:
H (n-) = C ( 2n, n) -c (2n, n-1) (n = 0,1,2, ...)
Numbers by Cattleya - Code
With a combination of the number of operators
Calculation of the composition
for(int i=0; i<=4000; i++)
c[i][0] = c[i][i] = 1;
for(int i=2;i<=n;i++)
for(int j=1;j<=i/2;j++) {
c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
c[i][i-j]=c[i][j];
}
Formula: h (n) = c ( 2n, n) - h (2n, n-1)
Note: int c [maxn] [maxn ]; to be written to main outside
for(int i=0; i<=4000; i++)
c[i][0] = c[i][i] = 1;
for(int i=2 ; i<=4000; i++)
for(int j=1; j<=i/2; j++){
c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mod;
c[i][i-j] = c[i][j];
}
cin >> n;
cout << (c[2*n][n] - c[2*n][n-1] + mod) % mod << endl;
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int maxn=2100;
ll dp[maxn];
ll mypow(ll a,ll b)
{
ll ans=1;
while(b)
{
if(b&1) ans=ans*a%mod;
a=a*a%mod;
b>>=1;
}
return ans;
}
int main(void)
{
int n;
scanf("%d",&n);
dp[1]=1;
for(int i=2;i<=n;i++)
dp[i]=dp[i-1]*(4*i-2) % mod * mypow(i+1,mod-2) % mod;
printf("%lld\n",dp[n]);
return 0;
}