标签:style blog color os io for div log amp
给定n个点(1~n)使他们构成二叉树 求高度大于h 的有多少种
#include <iostream> using namespace std; long long int tbl[36][36]; long long int get(int n, int h) { long long int &ans = tbl[n][h]; if (ans == -1) { ans = 0; if (n == 0) ans = 1; else if(h == 0) ans = 0; else for(int j = 0; j <= n-1; ++j) ans += get(j, h-1) * get(n-1-j, h-1); } return ans; } int main(void){ int n,h; cin >> n >> h; for (int i = 0; i <= n; ++i) fill_n(tbl[i], 36, -1); cout << get(n, n) - get(n, h-1) << endl; return 0; }
标签:style blog color os io for div log amp
原文地址:http://www.cnblogs.com/Susake/p/3936904.html