Editorial for COCI '12 Contest 6 #2 Sume
Submitting an official solution before solving the problem yourself is a bannable offence.
We will leave the case
Summing these equations we get
Now
Knowing the first element of the array, we easily determine the others:
If we want to avoid the above mentioned math, limitations for the elements given in the task allow us to try all possible values for the first element of the array. For each of these possibilities, we generate other elements of the array as shown in the previous paragraph and test the correctness of the array by summing any two elements different from the first. The question of why it works is left as an exercise to the reader.
For practice, consider this task where the cases that there is no solution or that there are infinitely many solutions are possible and to be detected.
Comments