#P8801. [蓝桥杯 2022 国 B] 最大数字

[蓝桥杯 2022 国 B] 最大数字

Problem Description

Given a positive integer NN. You may perform the following two operations any number of times on any digit of NN:

  1. Increase that digit by 11. If the digit is already 99, after adding 11 it becomes 00.

  2. Decrease that digit by 11. If the digit is already 00, after subtracting 11 it becomes 99.

Overall, you can perform operation 1 at most AA times, and operation 2 at most BB times.

What is the maximum value you can turn NN into?

Input Format

The first line contains three integers: NN, AA, BB.

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 30%30\% of the testdata, 1N1001 \leq N \leq 100; 0A,B100 \leq A, B \leq 10.

For 100%100\% of the testdata, 1N10171 \leq N \leq 10^{17}; 0A,B1000 \leq A, B \leq 100.

Lanqiao Cup 2022 National Contest, Group B, Problem D.

Translated by ChatGPT 5