A9270 | Counting Sticks
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? — That's right, using counting sticks! An here's our new task:
An expression of counting sticks is an expression of type:
\[ $A$ sticks\]\[sign +\]\[ $B$ sticks\]\[sign =\]\[ $C$ sticks\] $(1<=A,B,C)$ . Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if $A+B=C$ .
We've got an expression that looks like $A+B=C$ given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
An expression of counting sticks is an expression of type:
\[ $A$ sticks\]\[sign +\]\[ $B$ sticks\]\[sign =\]\[ $C$ sticks\] $(1<=A,B,C)$ . Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if $A+B=C$ .
We've got an expression that looks like $A+B=C$ given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.
We really aren't fabulous at arithmetics. Can you help us?
输入格式
The single line contains the initial expression. It is guaranteed that the expression looks like $A+B=C$ , where $1<=A,B,C<=100$ .
输出格式
If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.
输入输出样例
输入 #1
||+|=|||||
输出 #1
|||+|=||||
输入 #2
|||||+||=||
输出 #2
Impossible
输入 #3
|+|=||||||
输出 #3
Impossible
输入 #4
||||+||=||||||
输出 #4
||||+||=||||||
In the first sample we can shift stick from the third group of sticks to the first one.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.
There is no answer in the third sample because we cannot remove sticks from the expression.
In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted