Recent Div3 Contest Query

Revision en2, by Athreya1900, 2020-04-22 08:29:24

I was trying to code the problem Candies, yesterday and my logic was

In order to find a solution to

x + 2x + 4x ... = n

x(2^k — 1) = n

x = n / (2^k — 1 )

So I go through the factors of n in square root n time and check if they're of the same form as the denominator.

But apparently it times out, can someone shed some light on this?

Link to my submission

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Athreya1900 2020-04-22 08:29:24 17
en1 English Athreya1900 2020-04-22 08:28:50 462 Initial revision (published)