#C1199. Nodes Removal for Vine Transformation

    ID: 41366 Type: Default 1000ms 256MiB

Nodes Removal for Vine Transformation

Nodes Removal for Vine Transformation

In this problem, you are given a complete binary tree of height (h). In a complete binary tree, every non-leaf node has exactly two children. Your task is to determine the number of nodes with exactly two children that must be removed in order to convert the tree into a "vine" (a degenerate tree where every node has at most one child).

The mathematical formulation for the transformation is based on the formula: [ \text{nodes_to_remove} = 2^h - 1 ] For example, when (h=1), the answer is (2^1 - 1 = 1); when (h=3), the answer is (2^3 - 1 = 7).

If multiple test cases are provided, you need to compute the answer for each tree height separately.

inputFormat

The input is read from standard input (stdin).

The first line contains a single integer (T), the number of test cases. Each of the following (T) lines contains one integer (h), representing the height of a complete binary tree.

outputFormat

For each test case, print the number of nodes to remove (i.e., (2^h - 1)) on a separate line, written to standard output (stdout).## sample

1
1
1

</p>