https://www.acmicpc.net/problem/5355
Problem
You are on planet jj and they do math a bit differently. Math is done using the following operators : @, %, and #. @ is multiply by 3. % is add 5. # is subtract 7. That is all they can do in terms of math operations. Each expression will start with a number and then a list of operators.
Input
The first line in the data file will indicate the number of data sets to follow. Each data set will contain an expression to solve.
Output
Print out the answer formatted to 2 decimal places.
Code
n = int(input())
for _ in range(n):
jj = input().split(' ')
num = float(jj[0])
operators = jj[1:]
for i in operators:
if i == '@':
num *= 3
elif i == '%':
num += 5
else:
num -= 7
print("%0.2f" % num)
728x90
'파이썬알고리즘' 카테고리의 다른 글
백준 6603 파이썬 (0) | 2023.02.06 |
---|---|
Baekjoon 2775 Python (0) | 2022.11.20 |
백준 10816 파이썬 (0) | 2022.05.26 |
백준 10250 파이썬 (0) | 2022.05.15 |
백준 10866 (duque) 파이썬 (0) | 2022.05.10 |