309111: CF1626B. Minor Reduction

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Minor Reduction

题意翻译

给你一个整数x采用十进制表示法没有前导零。 你必须对其进行一次消减:取x中相邻的两个有效数字,并将他们替换为不带前导零的和(如果和为0,则表示为0) 例如,如果x=10057,可能的消减是: *选择第一个和第二个数字1和0,用1+0=1替换他们,结果是1057; 选择第二和第三个数字0和0,用0+0=0替换他们,则结果也为1057; 选择第三和第四个数字0和5,用0+5=5替换他们结果也为1057; 选择第四和第五个数字5和7,用 5+7=12替换他们,结果是10012; [输入] 第一行包含一个整数t (1≤t≤10e4)—测试的组数。 每一组测试组数由一个整数x组成 (10≤x<10e200000),x不包含前导0. [输出] 减少后可以获得的最大数量正好应用一次。该数字不应包含前导零。

题目描述

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 \le t \le 10^4 $ ) — the number of testcases. Each testcase consists of a single integer $ x $ ( $ 10 \le x < 10^{200000} $ ). $ x $ doesn't contain leading zeros. The total length of the decimal representations of $ x $ over all testcases doesn't exceed $ 2 \cdot 10^5 $ .

输出格式


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.

Input

题意翻译

给你一个整数x采用十进制表示法没有前导零。 你必须对其进行一次消减:取x中相邻的两个有效数字,并将他们替换为不带前导零的和(如果和为0,则表示为0) 例如,如果x=10057,可能的消减是: *选择第一个和第二个数字1和0,用1+0=1替换他们,结果是1057; 选择第二和第三个数字0和0,用0+0=0替换他们,则结果也为1057; 选择第三和第四个数字0和5,用0+5=5替换他们结果也为1057; 选择第四和第五个数字5和7,用 5+7=12替换他们,结果是10012; [输入] 第一行包含一个整数t (1≤t≤10e4)—测试的组数。 每一组测试组数由一个整数x组成 (10≤x<10e200000),x不包含前导0. [输出] 减少后可以获得的最大数量正好应用一次。该数字不应包含前导零。

加入题单

算法标签: