From 84612f0471fae071076dae02e5f05f4a39ba4fe7 Mon Sep 17 00:00:00 2001 From: H0ngJu Date: Sat, 16 Mar 2024 22:54:18 +0900 Subject: [PATCH] 2024-03-16 --- H0ngJu/README.md | 1 + ...24\354\204\270\355\221\270\354\212\244.py" | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 "H0ngJu/\352\265\254\355\230\204/\354\232\224\354\204\270\355\221\270\354\212\244.py" diff --git a/H0ngJu/README.md b/H0ngJu/README.md index af4ff40e..dd774916 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -3,5 +3,6 @@ | 차시 | 날짜 | 문제유형 | 링크 | 풀이 | | :---: | :--------: | :------: | :-------------------------------------------------------------------------: | :-------------------------------------------------: | | 1차시 | 2024.03.05 | 큐 | [프로세스](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 | +| 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