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 6+8+10
.
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
single
0
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...).
1 3 5
a rising sequence? What about1 7 22
? (in base 10) \$\endgroup\$1 3 5
and1 7 22
are both rising under base 10. So, the solution for both cases is10 10 10
, because we need to maximize the sum of bases while assuring that the sequence is rising when n-th number is interpreted as being written in base equal to n-th term of solution. \$\endgroup\$1 1 1
or3 3 4
are not rising. \$\endgroup\$