BOJ - 16503 - 괄호 없는 사칙연산
Updated:
import sys
def oper(x, y, operator):
if operator == '+':
return x + y
elif operator == '-':
return x - y
elif operator == '*':
return x * y
elif operator == '/':
return int(x / y)
def solution():
cal = list(map(str, input().split()))
a = int(cal[0])
b = int(cal[2])
c = int(cal[4])
ret1 = oper(a, b, cal[1])
ret1 = oper(ret1, c, cal[3])
ret2 = oper(b, c, cal[3])
ret2 = oper(a, ret2, cal[1])
print(min(ret1, ret2))
print(max(ret1, ret2))
solution()
https://www.acmicpc.net/problem/16503
Leave a comment