#P8801. [蓝桥杯 2022 国 B] 最大数字
[蓝桥杯 2022 国 B] 最大数字
Problem Description
Given a positive integer . You may perform the following two operations any number of times on any digit of :
-
Increase that digit by . If the digit is already , after adding it becomes .
-
Decrease that digit by . If the digit is already , after subtracting it becomes .
Overall, you can perform operation 1 at most times, and operation 2 at most times.
What is the maximum value you can turn into?
Input Format
The first line contains three integers: , , .
Output Format
Output one integer representing the answer.
123 1 2
933
Hint
[Sample Explanation]
Perform operation 2 twice on the hundreds digit, and perform operation 1 once on the tens digit.
[Test Case Scale and Constraints]
For of the testdata, ; .
For of the testdata, ; .
Lanqiao Cup 2022 National Contest, Group B, Problem D.
Translated by ChatGPT 5