[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 ...
随机推荐
- tp框架实现防止非法登录
<?phpnamespace Admin\Controller;use Think\Controller;class UserController extends Controller {//登 ...
- (转)myeclipse插件—SVN分支与合并详解【图】
svn作为版本控制软件被广泛用于众多公司的开发团队中,最多的场景就是一个项目上传svn后,一个组内的小伙伴在上边提交和更新代码以及解决冲突,其实这只是发挥了svn的很小的一部分功能. 先稍微介绍一下s ...
- JAVA 中数据库连接的方法之一
/** * 数据库连接类 * */ package com.cn.MysqlConnect; import java.sql.Connection;import java.sql.DriverMana ...
- jqGrid的选中行事件
http://blog.csdn.net/u014381863/article/details/50375121
- virtualbox 下windows与虚拟机实现文件共享---挂载
1.创建挂载目录: mkdir /mnt/share 2.挂载:mount /dev/cdrom /mnt/share 3.cd /mnt/share 3.虚拟机-设备-分配光驱-VBoxGuestA ...
- 总结A*,Dijkstra,广度优先搜索,深度优先搜索的复杂度比较
广度优先搜索(BFS) 1.将头结点放入队列Q中 2.while Q!=空 u出队 遍历u的邻接表中的每个节点v 将v插入队列中 当使用无向图的邻接表时,复杂度为O(V^2) 当使用有向图的邻接表时, ...
- 04 Apache Solr: 目录结构
通过前面的介绍,我们已经能够看到管理员界面并对Solr形成了一个感性的认识.本篇将在物理上深入了解Solr的安装目录结构和Solr示例的主目录结构. 安装目录结构 Solr 6.3.0安 ...
- iOS强制横屏
由于项目需求,需要整个项目页面都是竖屏,唯独一个折线图页面强制性横屏显示. 网上逛了许多帖子,也看了好多大神的提供的方法,都没能够实现本屌丝想要的效果.没办法自己研究自己搞,借鉴各路大神的思路,最后费 ...
- Python基础之:List
Python:List (列表) list 为Python内建类型,位于__builtin__模块中,元素类型可不同,元素可重复,以下通过实际操作来说明list的诸多功能,主要分为增.删.改.查 li ...
- factory service provide自定义服务
1.factory factory , 就是你提供一个方法, 该方法返回一个对象的实例, 对于 AngularJS 的 factory 来说, 就是先定义一个对象, 给这个对象添加属性和方法, 然后返 ...