practivceAlgorithm/백준

[백준][Python] 2164 카드2

findTheValue 2021. 10. 19. 03:23

deque로 구현했습니다.

 

import sys
input = sys.stdin.readline
from collections import deque

N = int(input())
q = deque([i for i in range(1, N + 1)])
while len(q) != 1:
    q.popleft()
    if len(q) == 1:
        break
    q.rotate(-1)

print(q.pop())