Input
첫째 줄에 n이,
둘째 줄에 k가 주어진다.
셋째 줄부터 n개 줄에는 카드에 적혀있는 수가 주어진다.
1 | import sys |
Brute Force
순회하는 순서에 따라 조합이 달라짐 = 순열
python library
itertools.permutations
- input: iterable[, choice]
- output: possible combinations (iterable)
1
2
3# 순열
# nPk
from itertools import permutations결과가 같은 경우는 제외 = set
1
ret = set()
1
2
3# k-length possible combinations (tuples)
for per in permutations(s, k):
ret.add(''.join(per))
Output
첫째 줄에 상근이가 만들 수 있는 정수의 개수를 출력한다.
1 | print(len(ret)) |