Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

짱이 될거야

백준 1158: 요세푸스 문제 Python 본문

알고리즘

백준 1158: 요세푸스 문제 Python

jeong57 2022. 12. 1. 15:18

 

N, K = map(int, input().split())
arr = [i for i in range(1, N+1)]
result = []

num = 0
for _ in range(N):
    num += (K-1)
    num %= len(arr)
    result.append(str(arr.pop(num)))

print("<" + ", ".join(result)+">", sep=" ")
Comments