from collections import deque
def main():
n = int(input())
arr = deque(input())
dict = []
for _ in range(n):
dict.append(int(input()))
xrr = deque()
while arr:
if len(arr)==1:
# print(float(xrr[0]))
print("{:.2f}".format(xrr[0]))
break
x = arr.popleft()
# print(x)
if ord(x) >= 65 and ord(x) <= 90:
# ord(x) - 65 # A == 0
xrr.append(dict[ord(x) - 65])
# print(xrr)
else:
b = xrr.pop()
a = xrr.pop()
s = eval(f'a {x} b')
# print(s)
xrr.append(s)
단순 스택문제였다
후위 표기식이 뭔지 기억이 안 나서 찾아봐야했다
'Koala - 19기 > 코딩테스트 심화 스터디' 카테고리의 다른 글
[백준/python] 16401 : 과자 나눠주기 (0) | 2025.07.07 |
---|---|
[BOJ/C++] 3273번: 두 수의 합 (0) | 2025.07.06 |
[백준/Python] #7662: 이중 우선순위 큐 (0) | 2025.07.06 |
[PYTHON/백준] 11279 최대힙 (0) | 2025.07.06 |
[백준/python] 2075번 : N번째 큰 수 (0) | 2025.07.06 |