题目链接 九度oj 1412
利用 f[ n ] = f[0] * f[ n - 1] + f[1] * f[ n - 2] + ... + f[n - 1] * f[0]来计算
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 typedef long long LL; 5 const int Max = 1000; 6 LL f[Max + 10]; 7 void catalan() //套公式求 8 { 9 f[0] = 1; 10 for(int i = 1; i <= Max; i++) 11 { 12 f[i] = 0; 13 for(int j = 0; j < i; j++) 14 { 15 f[i] += f[j] * f[i - 1 - j]; 16 } 17 } 18 } 19 int main() 20 { 21 int n; 22 catalan(); 23 while(scanf("%d", &n) != EOF) 24 { 25 cout << f[n / 2] << endl; 26 } 27 return 0; 28 }