#QHD0000028. Cây sinh trưởng (Growing Trees)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Cây sinh trưởng (Growing Trees)
Growing Trees
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A mathematical tree grows level by level. At each level, each existing branch either splits into two branches or remains a single branch. Its growth follows these rules:
- At level , the tree does not branch.
- If a branch does not split at level , that branch must split at level .
- If a branch splits at level , exactly one of its two new branches splits at level , while the other does not.
Branches never merge. A leaf is an endpoint of a branch at the level being observed. Given a growth level , determine the number of leaves at that level.
It does not matter which one of the two children splits: the total number of leaves remains the same.
Input
One line containing a positive integer , the level of growth to examine.
Output
Print the number of leaves at level .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
3
Output
2
Explanation
Under the growth rules, the leaf counts at the first two levels are both . At level , the count equals the sum for the preceding two levels: . Thus the answer is .