CF1626B.Minor Reduction
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a decimal representation of an integer x without leading zeros.
You have to perform the following reduction on it exactly once: take two neighboring digits in x and replace them with their sum without leading zeros (if the sum is 0 , it's represented as a single 0 ).
For example, if x=10057 , the possible reductions are:
- choose the first and the second digits 1 and 0 , replace them with 1+0=1 ; the result is 1057 ;
- choose the second and the third digits 0 and 0 , replace them with 0+0=0 ; the result is also 1057 ;
- choose the third and the fourth digits 0 and 5 , replace them with 0+5=5 ; the result is still 1057 ;
- choose the fourth and the fifth digits 5 and 7 , replace them with 5+7=12 ; the result is 10012 .
What's the largest number that can be obtained?
输入格式
The first line contains a single integer t ( 1≤t≤104 ) — the number of testcases.
Each testcase consists of a single integer x ( 10≤x<10200000 ). x doesn't contain leading zeros.
The total length of the decimal representations of x over all testcases doesn't exceed 2⋅105 .
输出格式
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.
输入输出样例
输入#1
2 10057 90
输出#1
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.