[백준 1158][Python] 요세푸스 문제

봉글렛·2023년 2월 7일

백준

목록 보기
47/55

문제 링크 https://www.acmicpc.net/problem/1158

잘 따라가면 됨

풀이

n, k = map(int, input().split())
s = [i for i in range(1, n+1)]
result = []
t = 0
while s:
    t = (t+k-1) % len(s)
    result.append(str(s.pop(t)))

print("<"+', '.join(result)+">")
profile
어쩌다 개발자 (할 수 있을 때까지!!!!)

0개의 댓글