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. 注解式开发spring定时器

    1:spring 配置文件中增加这句    <task:annotation-driven/>  2:确保扫描程序能够扫描后  下面第3步骤的java类    <context:co ...

  2. sql遍历

    DECLARE @BTime DATETIME,@ETime DATETIME;DECLARE @Temp TABLE (ID BIGINT IDENTITY(1,1),aid BIGINT,newc ...

  3. 关于ajax载入窗口使用RedirectToAction在窗口显示的问题

    在过滤器中过滤用户是否登录,没有登录就RedirectToAction("Login", "Auth", new { Area = "Account& ...

  4. db2 重启

    DB2重启数据库实例时,有时停止实例会失败,此时需要先确认没有应用链接数据库,然后再关闭数据库实例,并重新启动. 1.查看是否有活动的链接 命令:db2 list applications for d ...

  5. easyui 下拉树改造

    <select id="cc" style="width: 250px"></select> <div id="sp&q ...

  6. String和string的区别(C#)

    从位置讲: 1.String是.NET  Framework里面的String,小写的string是C#语言中的string 2.如果把using System;删掉,没有大写的String了,Sys ...

  7. iOS中坐标转换

    坐标转换,可以用UIVIew的方法 //由要转换坐标view的superView执行该方法,rect为待转换view的frame,view是要显示到哪儿的 - (CGRect)convertRect: ...

  8. ebtables hook

    1 概述 netfliter框架不仅仅在ipv4中有应用,bridge,ipv4,ipv6,decnet 这四种协议中都有应用,其中ipv4中又分开了arp和ip的两种 其实netfliter是个大的 ...

  9. 122. Best Time to Buy and Sell Stock(二) leetcode解题笔记

    122. Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price ...

  10. DHCP配置

    DHCP服务器IP:192.168.1.10 一,安装dhcp [root@localhost ~]# yum install dhcp Loaded plugins: product-id, sub ...