B. Minor Reduction
You are given a decimal representation of an integer without leading zeros.
You have to perform the following reduction on it exactly once: take two neighboring digits in and replace them with their sum without leading zeros (if the sum is , it's represented as a single ).
For example, if , the possible reductions are:
- choose the first and the second digits and , replace them with ; the result is ;
- choose the second and the third digits and , replace them with ; the result is also ;
- choose the third and the fourth digits and , replace them with ; the result is still ;
- choose the fourth and the fifth digits and , replace them with ; the result is .
What's the largest number that can be obtained?
The first line contains a single integer () — the number of testcases.
Each testcase consists of a single integer (). doesn't contain leading zeros.
The total length of the decimal representations of over all testcases doesn't exceed .
For each testcase, print a single integer — the largest number that can be obtained after the reduction is applied exactly once. The number should not contain leading zeros.
2 10057 90
10012 9
The first testcase of the example is already explained in the statement.
In the second testcase, there is only one possible reduction: the first and the second digits.
0 Comments
If you have any doubts/suggestion/any query or want to improve this article, you can comment down below and let me know. Will reply to you soon.