짱이 될거야
백준 1158: 요세푸스 문제 Python 본문
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=" ")
'알고리즘' 카테고리의 다른 글
백준 20920: 영단어 암기는 괴로워 Python (0) | 2022.11.29 |
---|---|
백준 5014: 스타트링크 Python (BFS) (0) | 2022.11.29 |
백준 7569: 토마토 Python (BFS) (0) | 2022.11.28 |
백준 3009: 네 번째 점 Python (0) | 2022.11.25 |
백준 25501: 재귀의 귀재 Python (0) | 2022.11.25 |
Comments