Skip to main content

Checkpoint: The Last Number Standing

Challenge on lesson: Checkpoint — What Every Move Preserves

CHALLENGE
Difficulty: advanced+25 XP

**Task.** n numbers are written on a board (n ≥ 2). One move: erase two numbers a and b and write |a − b| instead. Repeat until one number remains. Print the parity (0 or 1) of that final number. **Constraints:** 2 ≤ n ≤ 200000; 0 ≤ a_i < 10^9. The sum may reach ~2·10^14. **Budget check:** no simulation is needed at all — find what every move preserves. But compute in a type wide enough to survive the full sum.

Back to lesson: Checkpoint — What Every Move Preserves