题解 | #有多少个不同的二叉搜索树#
有多少个不同的二叉搜索树
https://www.nowcoder.com/practice/16d23f940a084023b3be6019262589dc
#include <cstring> #include <iostream> using namespace std; int main() { int n; cin >> n; int f[n + 1]; memset(f, 0, sizeof f); f[1] = f[0] = 1; for(int i = 2; i <= n; i ++){ for(int j = 1; j <= i; j ++){ f[i] += f[j - 1] * f[i - j]; } } cout << f[n] << endl; }