diff --git a/H0ngJu/README.md b/H0ngJu/README.md index 1bf41770..2d0adb09 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -6,5 +6,6 @@ | 2차시 | 2024.03.07 | 큐 | [다리를 지나는 트럭](https://school.programmers.co.kr/learn/courses/30/lessons/42583) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/153 | | 3차시 | 2024.03.10 | 힙 | [N번째 큰 수](https://www.acmicpc.net/problem/2075) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/156 | | 4차시 | 2024.03.13 | 힙 | [문제집](https://www.acmicpc.net/problem/1766) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/158 | +| 5차시 | 2024.03.16 | 구현 | [요세푸스 문제](https://www.acmicpc.net/problem/1158) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/161 | --- diff --git "a/H0ngJu/\352\265\254\355\230\204/\354\232\224\354\204\270\355\221\270\354\212\244.py" "b/H0ngJu/\352\265\254\355\230\204/\354\232\224\354\204\270\355\221\270\354\212\244.py" new file mode 100644 index 00000000..387cd23d --- /dev/null +++ "b/H0ngJu/\352\265\254\355\230\204/\354\232\224\354\204\270\355\221\270\354\212\244.py" @@ -0,0 +1,27 @@ +import sys + +def input(): + return sys.stdin.readline().rstrip() + +def solution(k): + location = 0 + cnt = 0 + + while table: + if cnt == k - 1: + answer.append(table.pop(location)) + location -= 1 # 삭제한 경우에는 위치를 앞으로 이동 + cnt = 0 + else: + cnt += 1 + if len(table) != 0: + location = (location + 1) % len(table) + + return answer + +n, k = map(int, input().split()) +table = [i + 1 for i in range(n)] +answer = [] + +solution(k) +print("<" + ", ".join(map(str, answer)) + ">") \ No newline at end of file