QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#2951. 数字串的“午餐化”

統計

大家都听说过“头韵互换”(spoonerisms),它以牛津大学教授 William Archibald Spooner 的名字命名,他习惯交换单词的前缀,往往会产生滑稽的效果。“May I show you to your seat?” 变成了 “May I sew you to your sheet?”,“a crushing blow” 变成了 “a blushing crow”。

试想一下,如果他是一名算术学生,偶尔会交换他正在计算的数字的前缀,然后纳闷为什么他的等式总是毫无意义。例如,当他写下:

$$92 + 2803 = 669495$$

他真正想写的是:

$$6692 + 2803 = 9495$$

(他交换了第一个和第三个数字的前缀 “9” 和 “669”。)当他写下:

$$6891 * 723 = 4979753$$

他真正想写的是:

$$7291 * 683 = 4979753$$

(他交换了第一个和第二个数字的前缀 “72” 和 “68”。)

批改小 Spooner 先生的作业是一项巨大的挑战。快来帮帮他吧!

输入格式

输入包含一行,为一个形如 “$x + y = z$” 或 “$x * y = z$” 的表达式,其中 $x, y$ 和 $z$ 是小于 $2^{31}$ 的正整数。“$+$” 和 “$*$” 运算符以及 “$=$” 号周围会有单个空格。该表达式本身不是一个数学上正确的等式。

输出格式

输出一个数学上正确的等式,该等式由输入行通过交换三个数字 $x, y, z$ 中任意两个的真前缀(proper prefix)得到。(字符串 $s$ 的真前缀是指既不为空也不等于 $s$ 本身的字符串。)数字、运算符和 “$=$” 号之间用单个空格分隔。正确等式中的所有整数均为非负且小于 $2^{31}$。保证通过交换真前缀可以形成唯一一个正确的等式。

样例

输入格式 1

92 + 2803 = 669495

输出格式 1

6692 + 2803 = 9495

输入格式 2

6891 * 723 = 4979753

输出格式 2

7291 * 683 = 4979753

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.