← All problemsSign in

Subtraction Game 1

CodeChefRating 1250Open on judge ↗

Chef is playing a game on a sequence of N positive integers, say A1, A2, ... AN. The game is played as follows. - If all the numbers are equal, the game ends. - Otherwise - Select two numbers which are unequal - Subtract the smaller number from the larger number - Replace the larger number with the result from above (see the explanation section for clarity) Chef has already figured out that

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