Skip to content

Commit

Permalink
solve : 2164 카드2
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed May 7, 2024
1 parent 393edf7 commit df1cdb2
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions python/boj_2164.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys
from collections import deque

input = sys.stdin.readline


def solution(n):
queue = deque()
[queue.append(i) for i in range(1, n+1)]

while len(queue) > 1:
# 제일 위에 있는 카드를 바닥에 버린다
queue.popleft()

# 그 다음 제일 위에 있는 카드를
num = queue.popleft()

# 제일 아래에 있는 카드 밑으로 옮긴다
queue.append(num)

return queue.popleft()


def display_result(answer):
print(answer)


def main():
n = int(input())
answer = solution(n)
display_result(answer)


main()

0 comments on commit df1cdb2

Please sign in to comment.