Skip to content

Commit c7cb402

Browse files
committed
[BOJ]#1158. 요세푸스문제/실버4/20min
https://www.acmicpc.net/problem/1158
1 parent 7bdf288 commit c7cb402

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
[BOJ]#1158. 요세푸스문제: 실버 4
3+
https://www.acmicpc.net/problem/1158
4+
5+
-1 ~ n 번쨰 사람 중 순서대로 k 번째 사람 제거
6+
- 출력 : 제거되는 순서대로 출력
7+
8+
#FL0W
9+
유형 : 구현, 큐
10+
원형 큐 배치하기
11+
7,3 : 0~ 6
12+
<3, 6, 2, 7, 5, 1, 4>
13+
"""
14+
import sys
15+
N , K = map(int , sys.stdin.readline().split())
16+
17+
#1. 원형 큐 만들기
18+
elements = [i for i in range(1,N+1)]
19+
answer = []
20+
p = 0
21+
while elements :
22+
p = (p + K-1) % len(elements)
23+
answer.append(elements.pop(p))
24+
#2.출력
25+
print("<"+", ".join(list(map(str, answer))) + ">")

0 commit comments

Comments
 (0)