Skip to content

Commit

Permalink
solve : 11866 요세푸스 문제 0
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed May 3, 2024
1 parent 854ac87 commit 9824328
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions python/boj_11866.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys
from collections import deque

input = sys.stdin.readline


def solution(n, k):
queue = deque([i for i in range(1, n+1)])
answer = list()

while len(queue) > 0:
for _ in range(k-1):
tmp = queue.popleft()
queue.append(tmp)
num = queue.popleft()
answer.append(str(num))

return answer


def display_result(answer):
print("<", end="")
print(", ".join(answer), end="")
print(">", end="")


def main():
n, k = map(int, input().split())
answer = solution(n, k)
display_result(answer)


main()

0 comments on commit 9824328

Please sign in to comment.