Copyright © University of Cambridge. All rights reserved.
This problem is taken from the UKMT Mathematical Challenges.