Author: | Евгений Татаринов, Игорь Блинов | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 256 Mb | |
Output file: | Standard output |
The mountain is represented by a binary heap with n vertices, there is also a number k, which represents the sum of distances between all pairs of vertices. Given the value of k, find n.
In this context, a binary heap is an undirected binary tree that satisfies the following conditions:
For example, a binary heap with 4 vertices:
The input consists of a single line containing a natural number k.
Output n.
0 ≤ k ≤ 1018
The distance between the 1st and 2nd vertices is 1. The distance between the 1st and 3rd vertices is 1. The distance between the 1st and 4th vertices is 2. The distance between the 2nd and 3rd vertices is 2. The distance between the 2nd and 4th vertices is 1. The distance between the 3rd and 4th vertices is 3. The sum of all distances is 1 + 1 + 2 + 2 + 1 + 3 = 10.
No. | Standard input | Standard output |
---|---|---|
1 |
|
|