GFSSOC '15 Fall J3 - Equation Solver

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 32M

Authors:
Problem types

You've made it to the weekend, and you're ready to sleep! While trying to fall asleep, a nagging voice repeatedly commands you to do your math homework first. Since you want to sleep as soon as possible, you decide to do the problems super quickly. But there's a problem — your math teacher thought it was a funny joke to give you tons of super easy problems. The teacher also thought it was funny to replace + signs with the character P and - signs with the character M. Instead of wasting your time solving each one by hand, you decide to write a program to solve them. The questions will only involve subtraction and addition, and have up to 1\,000 terms with all numbers greater than 0 and less than or equal to 1\,000.

Input Specification

Line 1: The equation, a sequence of numbers, P, and M. Each term will be space separated from every other term. The equation will be terminated by =. There will be at least one term in the sequence.

Output Specification

Output one integer, the solution (right side) of the equation.

Sample Input

5 P 13 P 27 M 35 =

Sample Output

10

Comments


  • 1
    Arihan10  commented on July 7, 2019, 3:18 a.m. edit 3

    Ah... Time to pull out the good old snake again...


  • 3
    Kirito  commented on July 29, 2016, 12:28 a.m.

    Is the reason your math teacher is a troll because she knows Python?