https://www.acmicpc.net/problem/5613
1
2
3
4
5
6
7
8
9
10
11
12
|
operation='('+str(input())
while 1:
s=input()
if s=='=':
break
operation += s
if s.isnumeric():
operation+=')'
if operation.count('(')<operation.count(')'):
operation='('*(operation.count(')')-operation.count('('))+operation
operation=operation.replace('/','//')
print(eval(operation))
|
cs |
eval 함수를 쓰면 쉽게 구현가능함 -> 문자열대로 실행하는 함수
나누기는 문제 조건상 소숫점 버려야함(Line 11)
Use eval()
divide is limited in problem condition Like line 11
반응형
'python-algorithm' 카테고리의 다른 글
백준 2635 수 이어가기 (0) | 2022.10.27 |
---|---|
백준 16395 파스칼의 삼각형 (0) | 2022.10.27 |
백준 4447 좋은놈 나쁜놈 (0) | 2022.10.26 |
백준 25784 Easy-to-Solve Expressions (0) | 2022.10.26 |
백준 25704 출석 이벤트 (0) | 2022.10.26 |
댓글