Files
python/TangDou/LuoGuBook/P1044_2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

19 lines
566 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}