1170 - Counting Perfect BST BST is the acronym for Binary Search Tree. A BST is a tree data structure with the following properties. i)        Each BST contains a root node and the root may have zero, one or two children. Each of the children themsel…
题目大概就是求一个n个不同的数能构造出几种形态的二叉排序树. 和另一道经典题目n个结点二叉树不同形态的数量一个递推解法,其实这两个问题的解都是是卡特兰数. dp[n]表示用n个数的方案数 转移就枚举第几个数作为根,然后分成左右两子树,左右两子树的方案数的乘积就是这个数作根的方案数 另外就是题目得先找到[1,1e10]的perfect power,总共102230个:输入的区间[a,b],b-a>=1e6,也就是最多perfect power的个数大概就在a=1,b=1000001范围内,1110…
1170 - Counting Perfect BST   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB BST is the acronym for Binary Search Tree. A BST is a tree data structure with the following properties. i)        Each BST contains a root node…
链接: https://vjudge.net/problem/LightOJ-1170 题意: BST is the acronym for Binary Search Tree. A BST is a tree data structure with the following properties. i) Each BST contains a root node and the root may have zero, one or two children. Each of the chi…
题目链接: http://www.lightoj.com/volume_showproblem.php?problem=1170 题目描述: 给出一些满足完美性质的一列数(x > 1 and y > 1 such that m = xy.) 然后给出一个区间,问在这个区间中的完美数组成的搜索二叉树的个数是多少?解题思路: 1,打标算出所有的完美数列中的数字 2,打表算出卡特兰数列,等着以后用 3,卡特兰数列递推式:F[N] = F[N-1] * ( 4 * N - 2 ) / ( N + 1…
Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sight, won't you? Suppose the cinema only has one ticket-office and…
Buy the Ticket Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4726    Accepted Submission(s): 1993 Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the nex…
Buy the Ticket Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1886 Accepted Submission(s): 832   Problem Description The \\\\\\\"Harry Potter and the Goblet of Fire\\\\\\\" will be on show i…
Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sight, won’t you? Suppose the cinema only has one ticket-office and…
本文原题: LeetCode. 给定 n, 求解独特二叉搜寻树 (binary search trees) 的个数. 什么是二叉搜寻树? 二叉查找树(Binary Search Tree),或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值: 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值: 它的左.右子树也分别为二叉排序树. 举个栗子,给定 n = 3, 共有 5 个. 1 3 3 2 1 \ / / / \ \ 3 2 1…