Guardians of the Asgard

We are the protectors of Asgard planet. Thor have provided us with a mighty number n n , which is to be used to obtain a sequence of natural numbers. The sequence of numbers is the key to the survival of the planet. Can you find the sequence with the help of the following information? The sequence is a 0 , a 1 . . . . . . , a k a_{0} , a_{1} . . . . . . , a_{k} , where a 0 = 1 a_{0} = 1 and number of elements in sequence is minimum possible a i = n \sum a_{i} = n a i a i + 1 2 a i a_{i} \leqslant a_{i+1} \leqslant 2a_{i} k is minimum possible. We are assigned the task to find the number of terms in the sequence (we've to find k+1) when n = 981241785 n = 981241785 . Bonus : find all elements of the sequence Inspiration : code-forces


The answer is 29.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Qweros Bistoros
May 1, 2020

k = l o g 2 n k = \lfloor log_{2}{n} \rfloor

First let a i = 2 i a_i = 2^i for i k 1 i \le k-1 and a k = n 2 k + 1 a_k = n - 2^k + 1

Now just sort a i a_i ascending

@Qweros Bistoros can you please elaborate your solution.

Vikram Karki - 11 months, 4 weeks ago

Your solution seems incorrect because the last element in your solution might become lesser than its lower limit

Mayank Chaturvedi - 10 months, 2 weeks ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...