-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1935.py
46 lines (31 loc) · 799 Bytes
/
1935.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
numlist = []
ansList = []
s = input().rstrip()
for _ in range(n):
x = int(input())
numlist.append(x)
for i in s:
if ('A' <= i <= 'Z'):
x = ord(i) - ord('A')
real = numlist[x]
ansList.append(real)
else:
num2 = ansList.pop()
num1 = ansList.pop()
if i == '+':
a = num1 + num2
ansList.append(a)
elif i == '-':
a = num1 - num2
ansList.append(a)
elif i == '*':
a = num1 * num2
ansList.append(a)
elif i == '/':
a = num1 / num2
ansList.append(a)
print("%.2f" %(ansList[0]))