Find p such that 2^p starts with n

Правка en1, от prathams, 2015-07-04 16:55:27

Given value of n, how can we find the power(p) of 2 such that the result 2^p starts with n.

For ex —

n = 12 then answer is 7 i.e., 2^7 = 128.

n = 82 then answer is 209 i.e., 2^209 = 822752278660603021.........

If no such power exist then p should be -1.

I have coded it, but giving WA and TLE on some test cases. Here is the link to my code : link

How can we find power efficiently ? I got this problem on link

Теги math, number theory

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский prathams 2015-07-05 15:42:05 172
en1 Английский prathams 2015-07-04 16:55:27 540 Initial revision (published)