Problem 3984 --Minor Reduction

3984: Minor Reduction

"
Time Limit $2$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $3$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 字符串

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?

The first line contains a single integer tt (1≤t≤1041≤t≤104) — the number of testcases.

Each testcase consists of a single integer xx (10≤x<1020000010≤x<10200000). xx doesn't contain leading zeros.

The total length of the decimal representations of xx over all testcases doesn't exceed 2⋅1052⋅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.
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.

推荐代码 查看3984 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战 只能过个样例~~~ 807927 2022-01-24 22:17:44

赛题来源/所属竞赛 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛