백준 Python 2164 카드2

Seohyun·2023년 8월 8일

알고리즘

목록 보기
18/36

문제 링크

from collections import deque

n = int(input())

cards = deque([i for i in range(1, n+1)])

while True:
    
    if(len(cards) == 1):
        print(cards.popleft())
        exit()

    cards.popleft()
    cards.append(cards.popleft())
profile
Hail hamster

0개의 댓글