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. 树莓派 3 alsa 声卡驱动

    /boot/config.txt dtparam=i2c_arm=on,audio=on

  2. WebBrowser打开Word文档的一些注意事项

    WebBrowser打开Word文档的一些注意事项 分类: C#word2010-03-31 21:26 5640人阅读 评论(3) 收藏 举报 webbrowser文档browser工具object ...

  3. jquery EasyUI datagrid 的扩展

    接触 easyui 半年,js学的不深.大神请路过. 直接扩展 添加方法: $.extend($.fn.datagrid.methods, { getSelectedIndex: function ( ...

  4. 如何得到EF(ADO.NET Entity Framework)查询生成的SQL? ToTraceString Database.Log

    ADO.NET Entity Framework ToTraceString  //输出单条查询 DbContext.Database.Log  //这里有详细的日志

  5. 今天研究一下SVN的分支和合并

    关键字: trunk, branch, tag, merge 以前一直以为很难,没敢接触.今天晚上看了一下,也不过如此 用起来还是很简单的

  6. Android开源框架——Volley

    Volley 是 Google 在 2013 I/O 大会上推出的 Android 异步网络请求框架和图片加载框架.特别适合数据量小,通信频繁的网络操作.Volley 主要是通过两种 Diapatch ...

  7. wkhtmltopdf中文显示空白或者乱码方框

    中文乱码或者空白解决方法 如果wkhtmltopdf中文显示空白或者乱码方框 打开windows c:\Windows\fonts\simsun.ttc拷贝到linux服务器/usr/share/fo ...

  8. 纯JS实现中国行政区域上下联动选择地址

    一.实现目的: 如标题所述,通过JS来实现地址的选取,上一篇博客介绍的方式是通过java读取txt资源文件来实现地址的选择,通过ajax方式访问服务器实现省市区联动.此篇中将介绍如何使用JS实现相同功 ...

  9. netcat使用

    一.端口监听(实时消息) 首先在A计算机上,它充当的是服务器角色,$ nc -l 3333 这时就创建了一个监听端口(listening socket(server)).- -l 它让 nc 监听一个 ...

  10. arch linux 安装 之 ---GPT--引导篇

    新入一二手X240 ,直接格式化,装archLinux. 一.引导程序安装--------------- 1.首先搞清楚什么是UEFI Under UEFI下的引导顺序 System switched ...