백준 [ALGORITHM] - 카드 놓기 (5568)

2023. 6. 12. 09:33코딩/백준 [ALGORITHM]

반응형
from itertools import permutations

n = int(input())
k = int(input())

lst = []
num = []

for i in range(n):
    x = int(input())
    num.append(x)

permutations = permutations(num, k)

for permutation in permutations:
    number = int(''.join(map(str, permutation)))
    lst.append(number)

print(len(set(lst)))

파이썬의 itertools에 조합으로 정수를 만들어주는 함수가 있는 걸 알게 되었다.

근데 시간 생기면 직접 만들어볼 예정

반응형