Problem Introduction

In the problem, your goal is to add parentheses to a given arithmetic expression to maximize its value.

Problem Description

Task.Find the maximum value of an arithmetic expression by specifying the order of applying its arithmetic operations using additional parentheses.

Input Format.The only line of the input contains a string \(s\) of length \(2n+1\) from some \(n\), with symbols \(s_0, s_1, \cdots, s_{2n}\). Each symbol at an even position of \(s\) is a digit(that is, an integer from 0 to 9) while each symbol at an odd position is one of three operations from \(\{+,-,*\}\).

Constraints.\(1 \leq n \leq 14\)(hence the string contains at most 29 symbols).

Output Format.Output the maximum possible value of the given arithmetic expression among different orders of applying arithmetic operations.

Sample 1.
Input:

1+5

Output:

6

Sample 2
Input:

5-8+7*4-8+9

Output:

200

Solution

[UCSD白板题] Maximize the Value of an Arithmetic Expression的更多相关文章

  1. [UCSD白板题] Longest Common Subsequence of Three Sequences

    Problem Introduction In this problem, your goal is to compute the length of a longest common subsequ ...

  2. [UCSD白板题] Compute the Edit Distance Between Two Strings

    Problem Introduction The edit distinct between two strings is the minimum number of insertions, dele ...

  3. [UCSD白板题] Take as Much Gold as Possible

    Problem Introduction This problem is about implementing an algorithm for the knapsack without repeti ...

  4. [UCSD白板题] Primitive Calculator

    Problem Introduction You are given a primitive calculator that can perform the following three opera ...

  5. [UCSD白板题] Points and Segments

    Problem Introduction The goal in this problem is given a set of segments on a line and a set of poin ...

  6. [UCSD白板题] Number of Inversions

    Problem Introduction An inversion of a sequence \(a_0,a_1,\cdots,a_{n-1}\) is a pair of indices \(0 ...

  7. [UCSD白板题] Sorting: 3-Way Partition

    Problem Introduction The goal in this problem is to redesign a given implementation of the randomize ...

  8. [UCSD白板题] Majority Element

    Problem Introduction An element of a sequence of length \(n\) is called a majority element if it app ...

  9. [UCSD白板题] Binary Search

    Problem Introduction In this problem, you will implemented the binary search algorithm that allows s ...

随机推荐

  1. Java垃圾回收机制 入门

    对于Java虚拟机的了解,我认为是一个Java程序员已经入门的重要标志,而JVM中的垃圾回收机制(Garbage Collection,简称GC)又是JVM中的重点,所以hans在这里用篇文章时间和大 ...

  2. NPOI MVC 模型导出Excel通用类

    通用类: public enum DataTypeEnum { Int = , Float = , Double = , String = , DateTime = , Date = } public ...

  3. 树莓派 config.txt

    树莓派开机默认配置文件:/boot/config.txt # For more options and information see # http://www.raspberrypi.org/doc ...

  4. PDF打水印加密

    using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using S ...

  5. css:去掉手机浏览器上点击时的边框和阴影

    outline:none;(去掉蓝框) -webkit-tap-highlight-color:rgba(0,0,0,0) ;(去掉阴影)适用于ios,Android

  6. ————weak 和————block

    Blocks理解: Blocks可以访问局部变量,但是不能修改 如果修改局部变量,需要加__block __block int multiplier = 7; int (^myBlock)(int) ...

  7. css中clip-path属性的运用

    今天看到一位同学的需求,要在一个div中加一个小尖尖,对话时发的图片,旁边这个三角是怎么实现与图片的颜色一致,效果如下: 当然,解决这个问题有各种奇淫巧技,现在我们来看一个css属性clip-path ...

  8. AspNetPager分页控件使用方法

    一.下载AspNetPager.dll 二.AspNetPager.dll复制于应用程序下的bin目录,打开解决方案,引用dll文件 三. 在工具栏中添加控件,这样可以支持拖拽使用 四. 要使用Asp ...

  9. 编译Hadoop

    Apache Hadoop 生态圈软件下载地址:http://archive.apache.org/dist/hadoop/hadoop下载地址 http://archive.apache.org/d ...

  10. JMeter - 参数化

    方法一:使用"函数助手"添加从文件中读取参数的函数 (a)__StringFromFile函数:[读取整行数据]1.新建参数文件: