codeshark.ir is an Iranian judge. ( like ProjectEuler )

Me ( M_H_M ), Iman ( IMAN_GH ) & Hamid ( ITDOI ) prepared the round #4 :

It is my problem :

In MooSooLestan, there are lots of strange trees with unlimited vertices.

strangest one is MooSooLi's tree :

---- The degree of each vertex(the number of adjacent's vertices) is equal to the id of that vertex.

---- The tree is rooted from vertex with id 1.

---- If x < y, the whole id of x's children fewer than y's children. ---- The id of vertices are natural numbers.

There is another tree named MoosMasak which is really same as MooSooLi's tree with one difference.

The difference is the number of each vertex's children with x is equal to biggest power of 2 that x is divisible by that.

Left : MooSooLi ---- Right : MoosMasak

Subtasks :

1) What is the sum of ancestors of 10 ^ 12 in MooSooLi?

2) What is the sum of ancestors of 10 ^ 12 in MoosMasak?

3) What is the sum of subtree of 17 in heights [0, 9) in MooSooLi?

4) What is the sum of subtree of 17 in heights [0, 18) in MoosMasak?