← All problemsSign in

Two Variables

CodeChefRating 1973Open on judge ↗

Chef played an interesting game yesterday. This game is played with two variables $X$ and $Y$; initially, $X = Y = 0$. Chef may make an arbitrary number of moves (including zero). In each move, he must perform the following process: - Choose any positive integer $P$ such that $P \cdot P \gt Y$. - Change $X$ to $P$. - Add $P \cdot P$ to $Y$. Unfortunately, Chef has a bad memory and he has forgotte

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