문제 링크: https://www.acmicpc.net/problem/15665
백준 알고리즘 기초 2/2 510에서 11번째 - 15665번 N과 M (11)를 풀어보았다.
풀이:
파이썬의 경우 product을 쓰고, set을 써서 중복을 제거했다.
C++
Python
from itertools import product
n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr.sort()
res=list(set(product(arr,repeat=m)))
res.sort()
for i in res:
for j in i:
print(j,end=' ')
print()
Java
'코테용 문제풀이 > 백준' 카테고리의 다른 글
다음 순열 풀이 (0) | 2023.01.25 |
---|---|
N과 M (12) 풀이 (0) | 2023.01.25 |
N과 M (10) 풀이 (0) | 2023.01.24 |
N과 M (9) 풀이 (0) | 2023.01.24 |
N과 M (8) 풀이 (0) | 2023.01.24 |