diff --git a/python/boj_2164.py b/python/boj_2164.py new file mode 100644 index 0000000..a06b410 --- /dev/null +++ b/python/boj_2164.py @@ -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() \ No newline at end of file