728x90
반응형
기본적인 덱 문제이다. 2164 카드2와 거의 동일한 문제이다.
from collections import deque
N = int(input())
queue = deque([i for i in range(1, N+1)])
while len(queue) > 1:
print(queue.popleft(), end=' ')
queue.append(queue.popleft())
print(*queue)
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 13417번 카드 문자열(python) (0) | 2021.03.06 |
---|---|
백준 알고리즘 2346번 풍선 터뜨리기(python) (0) | 2021.03.06 |
백준 알고리즘 1021번 회전하는 큐(python) (0) | 2021.03.06 |
백준 알고리즘 15828번 Router(python) (0) | 2021.03.06 |
백준 알고리즘 12789번 도키도키 간식드리미(python) (0) | 2021.03.06 |