CF898F.Restoring the Expression

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+' and one character '=' should be inserted into given sequence of digits so that:

  • character'+' is placed on the left of character '=',
  • characters '+' and '=' split the sequence into three non-empty subsequences consisting of digits (let's call the left part a, the middle part — b and the right part — c),
  • all the three parts a, b and c do not contain leading zeros,
  • it is true that a+b=c.

It is guaranteed that in given tests answer always exists.

一个形如 a+b=ca+b=c 的正确表达式被写出;其中 aa、bb 和 cc 均为不含前导零的非负整数。在该表达式中,“+”号和“=”号丢失了。任务是恢复该表达式。换言之,需在给定的数字序列中插入一个字符 + 和一个字符 =,使得:

  • 字符 + 位于字符 = 的左侧;
  • 字符 + 和 = 将该序列划分为三个非空的纯数字子序列(我们称左侧部分为 aa,中间部分为 bb,右侧部分为 cc);
  • 三部分 aa、bb 和 cc 均不含前导零;
  • 满足等式 a+b=ca + b = c。

保证在给定的测试数据中,答案一定存在。

输入格式

The first line contains a non-empty string consisting of digits. The length of the string does not exceed 106.

第一行包含一个非空的数字字符串。该字符串的长度不超过 10610^6。

输出格式

Output the restored expression. If there are several solutions, you can print any of them.

Note that the answer at first should contain two terms (divided with symbol '+'), and then the result of their addition, before which symbol'=' should be.

Do not separate numbers and operation signs with spaces. Strictly follow the output format given in the examples.

If you remove symbol '+' and symbol '=' from answer string you should get a string, same as string from the input data.

输出恢复后的表达式。如果存在多个解,输出任意一个即可。

注意:答案最开始应包含两个项(用符号 + 分隔),然后是它们相加的结果,结果前需加上符号 =。

数字与运算符之间不得添加空格。请严格遵循示例中给出的输出格式。

如果从答案字符串中移除符号 + 和符号 =,所得字符串应与输入数据中的字符串完全相同。

输入输出样例

  • 输入#1

    12345168

    输出#1

    123+45=168
  • 输入#2

    099

    输出#2

    0+9=9
  • 输入#3

    199100

    输出#3

    1+99=100
  • 输入#4

    123123123456456456579579579

    输出#4

    123123123+456456456=579579579

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

首页