QOJ.ac

QOJ

حد الوقت: 4 s حد الذاكرة: 2048 MB مجموع النقاط: 100

#7914. 高等算术

الإحصائيات

验证码正变得越来越复杂。起初只是简单的计算,比如 $7 + 2$,而现在,它已经演变成需要区分吉娃娃和双倍巧克力碎松饼。

为了对抗越来越聪明的机器人,互联网验证码生产公司(ICPC)这次又有了新花样:给定一张包含许多整数的失真图像,请找出使用给定的每个整数恰好一次,通过加法、乘法和任意括号所能表达的最大值。

在连续尝试解决这样一个验证码一小时未果后,Katrijn 感到非常沮丧。她决定编写一个程序,输出一个具有最大值的有效算术表达式。

输入格式

输入包含: 一行一个整数 $n$ ($1 \le n \le 10^5$),表示验证码中整数的个数。 一行 $n$ 个整数 $a$ ($1 \le a \le 10^6$),表示验证码中的整数。

输出格式

输出一个具有最大值的有效算术表达式,其中输入列表中的每个整数恰好被使用一次。遵循通常的运算优先级。输出的表达式最多可以使用 $10^6$ 个字符,且不得包含任何空格。对于任何可能的输入,这样的表达式都存在。

如果存在多个有效的解决方案,你可以输出其中任意一个。

样例

样例输入 1

4
1 2 3 4

样例输出 1

3*((1+2)*4)

样例输入 2

3
13 37 1

样例输出 2

(1+13)*37

样例输入 3

4
1 1 1 1

样例输出 3

((1+1)*(1+1))

Figure 1. 验证码示例:区分吉娃娃和双倍巧克力碎松饼

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.