#P2702. [NOI2003] 木棒游戏

[NOI2003] 木棒游戏

Description

Read an expression from input (the expression is guaranteed to be an incorrect equation).

If moving exactly one matchstick can make the equation correct, output the new equation; otherwise, output No.

Notes and constraints:

  1. Numbers in the expression can be positive or negative. The only operators are plus and minus, and there is exactly one equals sign. There are no parentheses, multiplication, or division, and sequences like ++, --, +-, or -+ will not appear.
  2. There will not be 88 or more consecutive digits in the expression (the absolute value of any number is at most 99999999999999).
  3. You may only move matchsticks that form digits; you cannot move the matchsticks that form the operators (+, -, =), so the plus sign, minus sign, and equals sign never change. Before and after the move, the digit shapes must strictly match the patterns for 090\sim9 shown in Figure 2.
  4. Numbers in the input expression will not start with 00, but numbers in the corrected equation are allowed to start with the digit 00.

Input Format

Read one line from standard input. The line contains an expression that ends with the # character (ASCII code 35). There are no spaces or other separators. The input strictly follows the logical specification. The string length is less than or equal to 10001000.

Note: There may be some characters after the # character that are unrelated to the problem.

Output Format

Write exactly one line to standard output.

If there is a solution, output the corrected equation in the same format as the input (ending with #, with no separators and no extra characters). In this case, the input guarantees the solution is unique.

If there is no solution, output No (uppercase N, lowercase o).

1+1=3#
1+1=2#
1+1=3+5#
No
11+77=34#
17+17=34#

Hint

Translated by ChatGPT 5