본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 10104번 Party Invitation

by 현장 2025. 1. 14.

-Code

k = int(input())
nums = [i for i in range(k + 1)]

for _ in range(int(input())):
    r = int(input())
    temp = [0]

    for i in range(1, len(nums)):
        if i % r != 0:
            temp.append(nums[i])
    nums = temp

for n in sorted(nums[1:]):
    print(n)