#abc257e. E - Addition and Multiplication 2
E - Addition and Multiplication 2
Score : points
问题描述
Takahashi 拥有一个整数 。最初,。
Takahashi 可以任意多次执行以下操作:
- 选择一个整数 。花费 日元(日本货币)将 替换为 。
Takahashi 的预算是 日元。在不超过预算的情况下,找出通过操作得到的最终 值的最大可能值。
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
5
5 4 3 3 2 5 3 5 3
Sample Output 1
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 .
Sample Input 2
20
1 1 1 1 1 1 1 1 1
Sample Output 2
99999999999999999999
Note that the answer may not fit into a -bit integer type.
update @ 2024/3/10 10:55:36