Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- React
- 깃
- 프리온보딩
- cleancode
- 파이썬
- 개발
- env
- mongodb
- 패스트캠퍼스
- 한빛미디어
- 원티드
- 환경변수
- 코드프레소
- pyladies
- Python
- pyladiesseoul
- 스터디
- git
- AWS
- 위코드
- 코테
- 리액트
- 전문가를위한파이썬
- 한빛
- 개발스터디
- flask
- fluentpython
- codepresso
- 예리님
- 플라스크
Archives
- Today
- Total
개발자가 내팔자
[BOJ] 백준 11866 요세푸스 문제 0 Python 본문
https://www.acmicpc.net/problem/11866
11866번: 요세푸스 문제 0
첫째 줄에 N과 K가 빈 칸을 사이에 두고 순서대로 주어진다. (1 ≤ K ≤ N ≤ 1,000)
www.acmicpc.net
from collections import deque
import sys
N, K = map(int, sys.stdin.readline().split())
q = deque([i for i in range(1, N + 1)])
print("<", end="")
while q:
for i in range(K - 1):
q.append(q.popleft())
print(q.popleft(), end="")
if q:
print(", ", end="")
print(">")
q를 계속 돌려서 뒤에 붙였는데 이게 효율이 좋은지는 딱히 모르겠다.
출력 방식이 특이해서 알아두면 좋을 것 같다.
'Algorithms' 카테고리의 다른 글
[Programmers] 완주하지 못한 선수 Python (0) | 2022.06.01 |
---|---|
[BOJ] 백준 1966 프린터 큐 Python (0) | 2022.05.30 |
[BOJ] 백준 1654 랜선 자르기 Python (0) | 2022.05.30 |
[BOJ] 백준 4179 불! Python (0) | 2022.05.30 |
[BOJ] 백준 7569 토마토 Python (0) | 2022.05.30 |
Comments