CF552E.Vanya and Brackets

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vanya is doing his maths homework. He has an expression of form , where _x_1, _x_2, ..., x__n are digits from 1 to 9, and sign represents either a plus '+' or the multiplication sign '*'. Vanya needs to add one pair of brackets in this expression so that to maximize the value of the resulting expression.

万尼亚正在做数学作业。他有一个形如 的表达式,其中 x1,x2,…,xnx_1, x_2, \dots, x_n 是从 1 到 9 的数字,符号 表示加号 '+' 或乘号 '*'。万尼亚需要在此表达式中添加一对括号,使得最终表达式的值最大化。

输入格式

The first line contains expression s (1 ≤ |s| ≤ 5001, |s| is odd), its odd positions only contain digits from 1 to 9, and even positions only contain signs  +  and  * .

The number of signs  *  doesn't exceed 15.

第一行包含表达式 ss(1 ≤ ∣s∣ ≤ 50011 ≤ |s| ≤ 5001,且 ∣s∣|s| 为奇数),其中 ss 的奇数位置仅包含数字 11 到 99,偶数位置仅包含运算符 ++ 和 \*。

乘号 \* 的个数不超过 1515。

输出格式

In the first line print the maximum possible value of an expression.

在第一行输出表达式的最大可能值。

输入输出样例

  • 输入#1

    3+5*7+8*4

    输出#1

    303
  • 输入#2

    2+3*5

    输出#2

    25
  • 输入#3

    3*4*5

    输出#3

    60

说明/提示

Note to the first sample test. 3 + 5 * (7 + 8) * 4 = 303.

Note to the second sample test. (2 + 3) * 5 = 25.

Note to the third sample test. (3 * 4) * 5 = 60 (also many other variants are valid, for instance, (3) * 4 * 5 = 60).

第一个样例测试的说明:3+5×(7+8)×4=3033 + 5 \times (7 + 8) \times 4 = 303。

第二个样例测试的说明:(2+3)×5=25(2 + 3) \times 5 = 25。

第三个样例测试的说明:(3×4)×5=60(3 \times 4) \times 5 = 60(也存在许多其他合法方案,例如 (3)×4×5=60(3) \times 4 \times 5 = 60)。

输入解题思路,AI测评打分。不知道怎么写?

首页