[UCSD白板题] Maximize the Value of an Arithmetic Expression
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的更多相关文章
- [UCSD白板题] Longest Common Subsequence of Three Sequences
Problem Introduction In this problem, your goal is to compute the length of a longest common subsequ ...
- [UCSD白板题] Compute the Edit Distance Between Two Strings
Problem Introduction The edit distinct between two strings is the minimum number of insertions, dele ...
- [UCSD白板题] Take as Much Gold as Possible
Problem Introduction This problem is about implementing an algorithm for the knapsack without repeti ...
- [UCSD白板题] Primitive Calculator
Problem Introduction You are given a primitive calculator that can perform the following three opera ...
- [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 ...
- [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 ...
- [UCSD白板题] Sorting: 3-Way Partition
Problem Introduction The goal in this problem is to redesign a given implementation of the randomize ...
- [UCSD白板题] Majority Element
Problem Introduction An element of a sequence of length \(n\) is called a majority element if it app ...
- [UCSD白板题] Binary Search
Problem Introduction In this problem, you will implemented the binary search algorithm that allows s ...
随机推荐
- layer弹出层不居中解决方案
layer弹出层不居中解决方案 代码头中加入以下代码即可 <!doctype html>
- Python常用模块学习
1.模块介绍 2.time & datetime模块 3.random 4.os 5.sys 6.shutil 7.json&pickle 8.shelve 9.xml处理 10.ya ...
- Shell 去掉文本中的空格
使用sed命令 将文件'aol1'中的空格去掉然后输出到'tmpFile'文件中 sed s/[[:space:]]//g aol1 > tmpFile
- 安装android
http://www.oschina.net/question/1463998_220998 http://www.cnblogs.com/zoupeiyang/p/4034517.html
- HTML5 新增属性和废除属性
删除的属性大多都是可以用CSS替代的一些样式属性 设置网页标题前面的小图标的大小:size <link rel="icon" href="demo_icon.gif ...
- uvm - dut
module dut(clk, rst_n, rxd, rx_dv, txd, tx_en); input clk; input rst_n; :] rxd; input rx_dv; :] txd; ...
- deeplab hole algorithm
最近看了几篇文章,其中均用到了hole algorithm. 最早用的就是deeplab的文章了,Semantic Image Segmentation with Deep Convolutional ...
- Dijkstra搜索算法
Dijkstra无向图 算法执行步骤如下: 上面两张图来源于:http://blog.csdn.net/v_july_v/article/details/6096981 很牛的大神,膜拜,此处有鲜花 ...
- h5弹框去掉ip地址
<script> window.alert = function(name){ var iframe = document.createElement("IFRAME" ...
- Android布局6大类
1:在我们Android开发中,常见的布局的方式有6大类 线性布局LinearLayout 相对布局RelativeLayout 表格布局TableLayout 单帧布局FrameLayout 绝对布 ...