10303专题

UVA 10303 How Many Trees?

题意:设f[i]表示一共有i个元素时二叉搜索树的个数,那么依次取1~n-1作为根节点,那么左右子树元素的个数就分别是(0,n-1),......,所以f[n] = f[0]*f[n-1]+f[1]*f[n-2]...+f[n-1]f[0],其实也就是Catalan数,高精度的计算,递推公式是f[n]=(4n-2)/(n+1)*f[n-1] #include <iostream>#include

uva 10303 - How Many Trees?(卡特兰数)

题目链接:uva 10303 - How Many Trees? 卡特兰数,公式num[i + 1] = num[i] * (4 * i - 6) / i ( i ≥ 3)。 #include <stdio.h>#include <string.h>#include <iostream>using namespace std;const int N = 6005;str

uva 10303 How Many Trees?

原题: A binary search tree is a binary tree with root k such that any node v reachable from its left has label(v) < label(k) and any node w reachable from its right has label(w) > label(k). It is a se

UVa 10303 How Many Trees? (卡特兰数高精度)

10303 - How Many Trees? Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=1244 A binary search tree is a bina