일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- spring
- deque
- 인프런
- 브루투포스
- LCM
- pypy3
- 소수판별
- python3
- 완전탐색
- 우선순위큐
- JPA
- c#
- 1일1솔
- 그리디 알고리즘
- C#강의
- DP
- BFS
- 백준
- 파이썬
- popleft
- 소수찾기
- mvc
- 연관관계
- 누적합
- Python
- unity
- appendleft
- 프로그래머스
- 합 구하기
- Java
Archives
- Today
- Total
jae_coding
(백준 자료구조 문제풀이) 1158번 요세푸스 문제 본문
반응형
문제
코드
import sys
from collections import deque
input = sys.stdin.readline
N, K = map(int, input().split())
lst = deque(i for i in range(1, N+1))
result = list()
count = 0
while len(lst) != 0:
count += 1
if count % K != 0:
lst.append(lst.popleft())
else:
result.append(lst.popleft())
ans = "<"
for i in result:
ans += str(i) + ", "
print(ans[:-2] + ">")
반응형
'알고리즘 문제 > 자료구조 문제' 카테고리의 다른 글
(백준 자료구조 문제풀이) 1874번 스택 수열 (0) | 2022.07.19 |
---|---|
(백준 자료구조 문제풀이) 10866번 덱 (0) | 2022.07.18 |
(백준 알고리즘 문제풀이) 18258번 큐 2 (0) | 2022.07.18 |
(백준 자료구조 문제풀이) 9012번 괄호 (0) | 2022.07.18 |
(백준 자료구조 문제풀이) 10828번 스택 (0) | 2022.07.18 |
Comments