Editorial for COCI '06 Contest 5 #4 Liga
Submitting an official solution before solving the problem yourself is a bannable offence.
Let the five numbers be ,
,
,
and
. We know that
and
. Additionally, all numbers are integers, at least
, and
is at most
.
The sample data shows that cases where one or two numbers are missing can be solved. It is less obvious that cases where three numbers are missing can be solved, and even some cases where four are missing (for example, 0 ? ? ? ?
or ? ? ? ? 300
).
Note first that and
can't both be unknown, except in the special case when
and
. If
and
were unknown, it would be possible to increase or decrease both numbers by one, and the solution would not be unique.
With that in mind, notice that if and
are known, then all other numbers can be calculated. The solution tries every possible pair
(each of the numbers is either fixed, or we try all values between
and
), calculates the other numbers and checks if the quintuplet satisfies the conditions.
Comments