标签:des style blog http color io os ar for
一个有n个结点的二叉树总共有多少种形态
读入一个正整数n
输出一个正整数表示答案
6
132
1<=n<=20
catalan数
f[2]=f[3]=1;
f[n+1]=(4n-6)/n*f[n];
1 # include<cstdio> 2 # include<cstring> 3 # include<iostream> 4 # include<algorithm> 5 using namespace std; 6 typedef unsigned long long LL; 7 const int maxn=25; 8 LL f[maxn]; 9 int main(){ 10 f[2]=f[3]=1; 11 for(int i=3;i<=maxn;i++) 12 f[i+1]=(4*i-6)*f[i]/i; 13 int n;cin>>n; 14 cout<<f[n+2]; 15 return 0; 16 }
标签:des style blog http color io os ar for
原文地址:http://www.cnblogs.com/zoniony/p/4004465.html