Power Writing
CodeChefOpen on judge ↗
Chef is learning to calculate power of a number. He is going to calculate **y-th** power of **x**. To learn his teacher gave him a task. He is going to write the result of **y-th** power of **x** in following way: **x** if **y=1** **(x*x^(y-1))** if **y** is **odd** number. **((x)^(y/2))^2** if **y** is an **even** number. He will repeat the process until no more changes can be done.
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