mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 13:56:26 +00:00
D - How many trees?
https://codeforces.com/contest/9/submission/176628922
This commit is contained in:
parent
81b0624c80
commit
27d663a4df
33
Codeforces/9/D/D.cpp
Normal file
33
Codeforces/9/D/D.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 40;
|
||||
|
||||
int n, h;
|
||||
long long f[N][N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> h;
|
||||
|
||||
for (int i = 0; i <= n; i++) {
|
||||
f[0][i] = 1;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
for (int k = 0; k < i; k++) {
|
||||
f[i][j] += f[k][j - 1] * f[i - k - 1][j - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << f[n][n] - f[n][h - 1] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user