http://codevs.cn/problem/1086/ (题目链接)
给出1~n总共n个数,对它们进行入栈出栈操作,问一共有多少种不同的方案。
找规律手玩前4个发现是卡特兰数,再见。
// codevs1086
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<queue>
#define MOD 1000000007
#define inf 2147483640
#define LL long long
#define free(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout);
using namespace std;
int main() {
	int n,f[20]={0};
	scanf("%d",&n);
	f[0]=1;f[1]=1;
	for (int i=2;i<=n;i++)
		for (int j=0;j<i;j++)
			f[i]+=f[j]*f[i-j-1];
	printf("%d",f[n]);
	return 0;
}
原文:http://www.cnblogs.com/MashiroSky/p/5921096.html