Editorial for COCI '07 Contest 6 #3 Granica


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

For 60\% of the score an easy brute force solution was available, trying every M between 0 and 10\,000 and checking whether all given integers give the same remainder when divided by M.

For the full score, we need the following deduction: if some two numbers A and B give the same remainder when divided by C, then C divides A-B. So for an integer M to be part of the output, it must divide the differences between each pair of input numbers. The largest such M is the greatest common divisor of the differences between input numbers. The remaining values of M are all divisors of the largest M (except for 1).


Comments

There are no comments at the moment.