Editorial for DMOPC '15 Contest 5 P3 - All Your Base


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.

Iterate up from A_{N-1}, converting A_{i-1} in base A_i. A language's built-in integer parsing function generally takes a second parameter denoting the base (parseInt in Java, int in Python, etc.) Notice that the bounds allow for base 1, in which case builtins will generally fail, so simply have a manual check for base 1.

Time Complexity: \mathcal{O}(N)


Comments

There are no comments at the moment.