#C9732. Subtree Sum Calculation
Subtree Sum Calculation
Subtree Sum Calculation
In this problem, you are given a rooted tree (conceptually) where each node holds an integer value. Your task is to compute the sum of all node values in the subtree rooted at a given node r. The sum is defined by the following rules:
- If \(r = 1\), then the sum is \(2^{31} - 1\) (i.e. 2147483647).
- For any other value of \(r\), the sum is \(2^{31} - 3\) (i.e. 2147483645).
Note that while a real tree would include an entire structure, for this problem you only need to consider the provided value of r to determine the result.
inputFormat
The input consists of a single integer r (\(1 \leq r \leq 10^9\)). This integer represents the new root of the subtree.
outputFormat
Output a single integer which is the sum of the values of the nodes in the subtree rooted at r. Follow the rules given in the problem statement.
## sample1
2147483647
</p>