CF1626B.Minor Reduction

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a decimal representation of an integer xx without leading zeros.

You have to perform the following reduction on it exactly once: take two neighboring digits in xx and replace them with their sum without leading zeros (if the sum is 00, it's represented as a single 00).

For example, if x=10057x = 10057, the possible reductions are:

  • choose the first and the second digits 11 and 00, replace them with 1+0=11+0=1; the result is 10571057;
  • choose the second and the third digits 00 and 00, replace them with 0+0=00+0=0; the result is also 10571057;
  • choose the third and the fourth digits 00 and 55, replace them with 0+5=50+5=5; the result is still 10571057;
  • choose the fourth and the fifth digits 55 and 77, replace them with 5+7=125+7=12; the result is 1001210012.

What's the largest number that can be obtained?

给你一个整数 xx 的十进制表示,不含前导零。

你需要恰好执行一次如下约简操作:选取 xx 中两个相邻的数字,并用它们的和(不带前导零;若和为 00,则表示为单个 00)来替换这两个数字。

例如,若 x=10057x = 10057,可能的约简方式有:

  • 选取第一位和第二位数字 11 和 00,将其替换为 1+0=11+0=1;结果为 10571057;
  • 选取第二位和第三位数字 00 和 00,将其替换为 0+0=00+0=0;结果也为 10571057;
  • 选取第三位和第四位数字 00 和 55,将其替换为 0+5=50+5=5;结果仍为 10571057;
  • 选取第四位和第五位数字 55 和 77,将其替换为 5+7=125+7=12;结果为 1001210012。

你能得到的最大数是多少?

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of testcases.

Each testcase consists of a single integer xx (10≤x<1020000010 \le x \lt 10^{200000}). xx doesn't contain leading zeros.

The total length of the decimal representations of xx over all testcases doesn't exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 表示测试用例的数量。

每个测试用例包含一个整数 xx(10≤x<1020000010 \le x \lt 10^{200000})。xx 的十进制表示中不含前导零。

所有测试用例中 xx 的十进制表示的总长度不超过 2⋅1052 \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.

示例中的第一个测试用例已在题目描述中解释完毕。

在第二个测试用例中,仅存在一种可能的化简操作:对第一位和第二位数字进行化简。

输入解题思路,AI测评打分。不知道怎么写?

首页