← All problemsSign in

Reduce to 1

CodeChefRating 2050Open on judge ↗

Arun has an integer $N$. His friend likes the number $1$, so Arun wants to reduce $N$ to $1$. To do so, he can perform the following move several times (possibly, zero): - Pick two integers $X$ and $Y$ such that $X+Y$ is even and $X^Y$ is a divisor of $N$. Then, replace $N$ by $\dfrac{N}{X^Y}$ Note that at each step, $X^Y$ only needs to be a divisor of the *current* value of $N$, and not necessa

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start