[파이썬(Python)] 백준 11866번 - 요세푸스 문제 0
2022. 3. 7. 19:54ㆍLanguage/python
https://www.acmicpc.net/problem/11866
11866번: 요세푸스 문제 0
첫째 줄에 N과 K가 빈 칸을 사이에 두고 순서대로 주어진다. (1 ≤ K ≤ N ≤ 1,000)
www.acmicpc.net
n, k = map(int, input().split())
list = []
for i in range(n):
list.append(i + 1)
ans = []
i = 0
while len(list) > 0:
i += k - 1
if i > len(list) - 1:
i = i % len(list)
ans.append(list[i])
list.pop(i)
print("<"+", ".join(map(str,ans))+">")'Language > python' 카테고리의 다른 글
| [파이썬(Python)] 프로그래머스 - 신규 아이디 추천 (1) | 2022.07.01 |
|---|---|
| [파이썬(Python)] 프로그래머스 - 로또의 최고 순위와 최저 순위 (0) | 2022.07.01 |
| [파이썬(Python)] 백준 10814번 - 나이순 정렬 (0) | 2022.02.07 |
| [파이썬(Python)] 백준 11050번 - 이항 계수 1 (0) | 2022.01.24 |
| [파이썬(Python)] 백준 1018번 - 체스판 다시 칠하기 (0) | 2022.01.24 |