We have a strictly increasing sequence of non-negative integers, like:
12 11 10
Wait! This sequence isn't strictly increasing, is it? Well, the numbers are written in different bases. The least possible base is 2, the biggest is 10.
The task is to guess bases each number is written, so that:
- the sequence is strictly increasing,
- the sum of the bases is maximised.
For instance, the solution for the sample will be:
6 8 10
because under those bases the sequence becomes
8 9 10 decimal - a strictly increasing sequence, and we are not capable of finding bases for which the sequence remains strictly increasing and whose sum is bigger than
Due to the second limitation a solution
3 5 7 is not satisfactory: in spite of fact that the sequence becomes
5 6 7 under those bases - we need to maximise the bases sum, and
3+5+7 < 6+8+10.
If under no bases
2<=b<=10 is it possible for the series to be strictly increasing, for instance:
102 10000 10
should be output.
The input sequence can be passed in the way it's most convenient for your solution (standard input / command line parameters / function arguments...).