Under construction

Still being built. Things may change

Postfix Expression Evaluation 2

Interview

Time limit2sMemory limit128 MB

Summary
Evaluate a postfix expression using given operand values and print the result rounded to two decimal places.
Level

Easy3 of 10

Topics
Stack, String, Implementation
Solved
No attempts yet

Problem

You are given a postfix expression and the value corresponding to each operand. Write a program that evaluates the expression.

Input

The first line contains the number of operands N. (1 <= N <= 26)

The second line contains the postfix expression. Operands are uppercase English letters starting from A, using exactly the first N letters in order. The expression length does not exceed 100.

From the third line through the N + 2-th line, one value is given for each operand. The third line is the value of A, the fourth line is the value of B, and so on. Each value is a natural number no greater than 100.

For every given input, while evaluating the postfix expression from left to right, the final result and every intermediate result are between -2,000,000,000 and 2,000,000,000, inclusive.

Output

Print the computed result rounded to exactly two digits after the decimal point.

Examples2

  1. Example 1

    Input
    5
    ABC*+DE/-
    1
    2
    3
    4
    5
    
    Expected output
    6.20
    
  2. Example 2

    Input
    1
    AA+A+
    1
    
    Expected output
    3.00