https://www.acmicpc.net/problem/11866
11866번: 요세푸스 문제 0
첫째 줄에 N과 K가 빈 칸을 사이에 두고 순서대로 주어진다. (1 ≤ K ≤ N ≤ 1,000)
www.acmicpc.net
# 11866 -Python 3
import sys
from collections import deque
input = sys.stdin.readline
n, k = map(int, input().split())
s = deque() # deque 선언
for i in range(1, n + 1):
s.append(i)
print('<', end="")
while s:
for i in range(k - 1):
s.append(s[0])
s.popleft()
print(s.popleft(), end="") # popleft를 통해 맨 왼쪽 값을 출력하면서 삭제
if s:
print(", ", end="")
print(">")'코딩' 카테고리의 다른 글
| [Python] 백준 #13909. 창문 닫기 (0) | 2023.03.29 |
|---|---|
| [Python] 백준 #10986. 나머지 합 (0) | 2023.03.24 |
| [Python] 백준 #2559. 수열 (0) | 2023.03.22 |
| [Python] 백준 #11659. 구간 합 구하기 4 (0) | 2023.03.22 |
| [Python] 백준 #2558. A + B - 2 (0) | 2023.03.22 |