#include <iostream>
#include <vector>
using namespace std;
vector<int> a(11);
long long rec(int i){
if(a[i])
return a[i];
long long sum=0;
for(int j=0;j<i;j++)
sum+=rec(j)*rec(i-j-1);
return a[i]=sum;
}
int main(){
a[0]=a[1]=1;
a[2]=2;
int n;
while(cin>>n){
cout<<rec(n)<<endl;
ws(cin);
if(!cin.eof())
cout<<endl;
}
}
#include <vector>
using namespace std;
vector<int> a(11);
long long rec(int i){
if(a[i])
return a[i];
long long sum=0;
for(int j=0;j<i;j++)
sum+=rec(j)*rec(i-j-1);
return a[i]=sum;
}
int main(){
a[0]=a[1]=1;
a[2]=2;
int n;
while(cin>>n){
cout<<rec(n)<<endl;
ws(cin);
if(!cin.eof())
cout<<endl;
}
}
Comments
Post a Comment