atcoder#ABC257E. [ABC257E] Addition and Multiplication 2
[ABC257E] Addition and Multiplication 2
Score : points
Problem Statement
Takahashi has an integer . Initially, .
Takahashi may do the following operation any number of times.
- Choose an integer . Pay yen (the currency in Japan) to replace with .
Takahashi has a budget of yen. Find the maximum possible value of the final resulting from operations without exceeding the budget.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
5
5 4 3 3 2 5 3 5 3
95
For example, the operations where and in this order change as:
.
The amount of money required for these operations is yen, which does not exceed the budget. Since we can prove that we cannot make an integer greater than or equal to without exceeding the budget, the answer is .
20
1 1 1 1 1 1 1 1 1
99999999999999999999
Note that the answer may not fit into a -bit integer type.