Add or Divide
CodeChefOpen on judge ↗
Narendra and Ayush are friends. Narendra loves math very much whereas Ayush loves binary form. Whenever Narendra is bored, Ayush comes with a number performing some operations. Ayush gives some positive number $K$ in its binary form and wants to make $K$ equal to $1$. He repeats the following operations while $K$ is greater than $1$ : If $K$ is even, then he divides $K$ by $2$, otherwise he add
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start