QOJ.ac

QOJ

时间限制: 3.0 s 内存限制: 1024 MB 总分: 100

#10431. 求值并返回

统计

Aidan 和 Nadia 是多年的好友,他们都对数学有着共同的热爱。他们每个人都有一个最喜欢的数字:Aidan 最喜欢的数字是 $p$,Nadia 最喜欢的数字是 $q$。

为了纪念他们的友谊,朋友们想制作一份礼物:一块刻有算术表达式的牌匾,其计算结果等于他们最喜欢的数字。乍一看,这似乎是不可能的,但答案很简单:Aidan 从左到右阅读,而 Nadia 从右到左阅读,因此同一个表达式对他们来说可以有不同的值。

例如,如果牌匾上写着 2023-12-13,那么 Aidan 计算的结果是 $2023 - 12 - 13 = 1998$,而 Nadia 计算的结果是 $31 - 21 - 3202 = -3192$。

请找出一个算术表达式,使得从左到右阅读时其计算结果为 $p$,从右到左阅读时其计算结果为 $q$。表达式的长度必须不超过 1000 个字符。题目保证对于所有合法的输入,这样的表达式都存在。

输入格式

输入的第一行包含两个整数 $p$ 和 $q$ ($-10^{18} \le p, q \le 10^{18}$)。

输出格式

输出该表达式,不要包含空格或换行符。它只能包含数字 0 到 9 以及字符 ‘+’、‘-’ 和 ‘*’。

表达式的长度必须不超过 1000 个字符。在表达式及其反转形式中,数字均不允许有前导零(唯一的例外是表示数字 0 的 ‘0’)。不允许使用一元运算符 ‘+’ 或 ‘-’。表达式在两个方向上都必须是良构的。计算过程遵循标准的运算符优先级。

样例

输入 1

1998 -3192

输出 1

2023-12-13

输入 2

413 908

输出 2

12*34+5

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.