I was trying to solve this problem from codeforces.

https://codeforces.com/contest/1098/problem/C

I understood upto the part where binary search was used to calculate the minimum value of branching coefficient but i am not able to build the tree from s, n and binary coefficient.

can someone explain the idea. Itβs not clear in the editorial.

link to editorial : https://codeforces.com/blog/entry/64331

I did not understand this part

We know that the tree can be rebuilt so that the sum is any between maximum and minimum, so there are two conditions, which are satisfied (we want to put value π₯x to position πi).

- π₯x must be big enough, so if we fill suffix with numbers π₯x, π₯β πxβ k, π₯β π2xβ k2, β¦ (the last non-zero number can be smaller, sum of numbers is πn) sum of sizes of subtrees will be not greater to π s.
- π₯x must be small enough, so if we fill suffix with 11, sum of sizes of subtrees will be not less than π s