#P4808. Balanced Trees
Balanced Trees
Balanced Trees
We define a Perfect Balanced Tree as follows:
- A tree with weight 1 consists of a single node and is considered a perfect balanced tree.
- For any tree of weight w (w ≥ 2), the tree is a rooted tree with k (2 ≤ k ≤ w) subtrees. All the k subtrees must be identical, and each subtree is itself a perfect balanced tree. In particular, the weight of each subtree is exactly \(\lfloor\frac{w}{k}\rfloor\).
Given an integer N, compute the number of perfect balanced trees of weight N.
inputFormat
The input consists of a single integer N, which represents the weight of the tree.
outputFormat
Output a single integer representing the number of perfect balanced trees with weight N.
sample
1
1