Editorial for COCI '13 Contest 1 #2 Kušač
Submitting an official solution before solving the problem yourself is a bannable offence.
It can be shown that the following cutting strategy is optimal. We arrange the sausages in a single line, one after the other (thus obtaining a line segment consisting of shorter line segments). Cutting this line into equal segments yields the required solution.
Although we are conceptually making cuts, some of them are not actual cuts, but fall between sausages (shorter line segments) instead. For example, with two sausages and four tasters, the first cut is real, dividing the first sausage in half, the second cut is not real because it is actually between the two sausages, and the third cut is real, dividing the second sausage in half.
We therefore need to count the "between" cuts. For the cut to be a between-cut, the first out of the portions must consist of the first sausages, where is an integer. In other words, out of sausages equals sausages. can then be obtained: . It is now clear that will be an integer (and the cut a between-cut) if divides . We can simply use a for loop to check, for each possible from to , whether it is a real cut or a between-cut.
Alternatively, there is an explicit formula: . Proof is left as an exercise for the reader.
Comments