Editorial for COCI '10 Contest 3 #2 Zbroj


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.

The key observation is that Perica can get the minimum number by replacing all occurrences of digit six with digit five. Likewise, he can obtain the maximum number by replacing all occurrences of digit five with digit six.

The simplest way to do this is to read in the input as strings and simply carry out the digit substitutions before converting them to integers and calculating the results.

An alternative solution is to read the numbers as integers and do direct integer manipulation to extract digits and make necessary substitutions.


Comments

There are no comments at the moment.