생각보다 어려웠던 문제다.
queue
를 이용하면 쉽게 풀 수 있다!
예를 들어 문제와 같이 K=3 이라면, 배열 앞에 2개를 popleft() 하고 뒤로 보내고 다시 한번 popleft()해서 정답 배열에 append 하면 된다. -> 배열이 빌 때까지 반복
<정답>
from collections import deque
N, K = map(int, stdin.readline().split())
human = deque()
for i in range(N):
human.append(i+1)
re = []
while len(human) >= 1:
for i in range(K-1):
human.append(human.popleft())
re.append(human.popleft())
#정답 출력
print('<', end='')
for i in range(N):
if i == N-1:
print(re[i], end='>')
else:
print(re[i], end=', ')