https://www.acmicpc.net/problem/10773
문제
내 풀이
import sys
input = sys.stdin.readline
n = int(input())
stack = []
for _ in range(n):
call = int(input())
if call != 0:
stack.append(call)
else:
stack.pop()
print(sum(stack))
해설
기본적인 파이썬 리스트 기능으로 stack을 재현에 문제를 풀었다.
정답 풀이
a,b = input().split()
a = int(a)
b = int(b)
print(a+b)
print(a-b)
print(a*b)
print(int(a/b))
#print(a//b)
print(a%b)
#print("%d\n%d\n%d\n%d\n%d"%(a+b, a-b, a*b, a/b, a%b))
출처:
해석
'sw사관학교 정글 2기 > 02 이분탐색, 분할정복, 스택, 큐, 우선순위 큐' 카테고리의 다른 글
[큐] 백준 11866번 요세푸스 문제0 with Python3 (0) | 2021.08.13 |
---|---|
[큐] 백준 2164번 카드2 with Python3 (0) | 2021.08.13 |
[큐] 백준18258번 큐 2 with Python3 (0) | 2021.08.13 |
[스택] 백준 17608번 막대기 with Python3 (0) | 2021.08.13 |
[스택] 백준 10828번 스택 with Python3 (0) | 2021.08.13 |
댓글