백준 15651번 N과 M (3) 문제

 

225932KB, 2648MS

 

이전번 문제와 동일하게 itertools의 product(중복순열)을 이용하였다.

특이하게 매개 값에 2 같은 정수형 자료가 들어가면 안되고

repeat = (int) x 로 반복 수를 넣어주어야 한다.

 

from itertools import product
n, m = map(int, input().split())
data = [i for i in range(1, n + 1)]
for i in product(data, repeat = m):
    for j in i:
        print(j, end=' ')
    print()

+ Recent posts