#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:
- 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. - There will not be or more consecutive digits in the expression (the absolute value of any number is at most ).
- 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 shown in Figure 2. - Numbers in the input expression will not start with , but numbers in the corrected equation are allowed to start with the digit .
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 .
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
京公网安备 11011102002149号