Editorial for JDCC '15 Contest 1 P4 - Basically Right

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.

Author: aurpine

It helps to know about the integer parsing functions part of most languages that accepts a base to interpret the string in. Using this method and checking all the strings will give an approximate \mathcal{O}(N) solution on the number of valid bases which runs in time.

However, if you experiment with a few numbers you will find that the highest mark is in either the highest or lowest base possible. Thus, we find the highest digit in the two numbers. The lowest base possible is one greater than the highest digit. The highest base as stated in the problem is one less than the denominator. Just check the two numbers and print the maximum.

Time Complexity: \mathcal{O}(1)


There are no comments at the moment.