You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
566 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
// h[i]i个元素一共有h[i]种出管方式
// 0个元素只有一种情况这种情况就是啥也不出啥也不出也算是一种场景。
// 1个元素只有一种情况就是出队列进栈出栈。
int n, f[20] = {1, 1};
int main() {
cin >> n;
for (int i = 2; i <= n; i++)
for (int j = 1; j <= i; j++)//最后出栈的元素假设是j
dp[i] += dp[j-1] * dp[i - j];//所有的可能性加在一起
printf("%d", dp[n]);
return 0;
}