[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 ...
随机推荐
- 利用 PortableBasemapServer 发布地图服务
前段时间需要给自己的C/S系统加一个地图,但是没有数据,于是就想到了使用网上的切片地图,但是C/S系统又不能联网,于是就想本地发布切片服务来使用. 本来想用ArcGIS Server来发布从网上下载的 ...
- [原创]Matlab之复选框使用
本文简单记录在Matlab的GUI设计中,复选框的一些使用,比较简单. 简单到直接上代码,就是可能比较容易忘记,使用的时候再翻回来好了. 1 2 3 4 5 6 7 % 复选框,选中后为1,未选中则为 ...
- [转载]Matlab之静态文本多行输出
转载文章,原文链接:Matlab中的静态文本框中显示多行内容 有时候,我们在GUI中利用静态文本框显示程序的结果,但是结果很长,一行未必可以显示的开,而静态文本框不像edit或listbox那样通过滚 ...
- TextView.setTextColor颜色值的理解
TextView.setTextColor(int value),括号里是int型的值,可以填充的值有三种情况. 第一种:系统自带的颜色类,TextView.setTextColor(android. ...
- 解決 java.security.cert.CertificateException: Certificates does not conform to algorithm constraints
找到 jre/lib/security/java.security 将 jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 ...
- HR开发 操作信息类型数据
1.通过函数操作. . DATA: ZRETURN TYPE BAPIRETURN1, ZPAKEY TYPE BAPIPAKEY. GET PERNR. LOOP AT P0001 WHERE .. ...
- 准备开发一款开源NES模拟器
前几天无意见看到一些NES的开发资料,勾起了小时候暑假的无数美好回忆,做为一名码农,萌发了自己写一款模拟器的想法.一来可以加深自己对整个系统/游戏的理解,一来可以实现小时候的梦想:),希望可以坚持下来 ...
- solr多词匹配搜索问题及解决
使用solr进行某较长词搜索时出现了一些问题,及解决方案. 1.问题:solr默认使用OR方式搜索,当搜索一个很长的次,比如“XX集团股份有限公司”,分词器分词后,使用OR方式匹配,会匹配到很多结果. ...
- 【摘】BPMN2.0-概要
BPMN2.0-概要 原文地址:http://www.uml.org.cn/workclass/201206272.asp 作者:AliKevin2011,发布于2012-6-27 一.BPM ...
- 关闭ctrl+shift+d截图
关闭ctrl+shift+d截图,最近用sublime text3的时候,用ctrl+shift+d,总是跳出来截图,找了半天,原来是百度浏览器的截图功能快捷键是ctrl+shift+d, 关掉即可