-
복습 1935 후위 표기식2코테 대비 python/백준 2023. 4. 14. 15:02
https://www.acmicpc.net/problem/1935
언제나 그렇듯 핵심은 자료구조를 사용하여 요구하는 것을 구현할 수 있는가??
사용한것 key-value
스택자료구조
출력시 f 사용 ==> 맨날까먹어ㅜㅜ
n=int(input()) a=list(input()) val=dict() alpa="ABCDEFGHIJKLMNOPQRSTUVWXYZ" cal=[] result=0 for i in range(n): val[alpa[i]]=int(input()) for i in a: if i in alpa: cal.append(val[i]) elif i == "*": a=cal.pop() b=cal.pop() cal.append(b*a) elif i == "+": a = cal.pop() b = cal.pop() cal.append(b + a) elif i == "-": a = cal.pop() b = cal.pop() cal.append(b - a) elif i == "/": a = cal.pop() b = cal.pop() cal.append(b / a) num=cal[0] print(f"{num:.2f}")
'코테 대비 python > 백준' 카테고리의 다른 글
18115 카드 놓기 (0) 2023.04.16 2580 스도쿠 (0) 2023.04.14 1181 단어 정렬 (0) 2023.04.11 14503 로봇 청소기 (0) 2023.04.11 1966 프린터 큐 (0) 2023.04.10