본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#116 백준 파이썬 [15651] N과 M (3) - 중복 순열

https://www.acmicpc.net/problem/15651

 

#Solution

https://claude-u.tistory.com/161 참고. 중복 순열을 위 해 product 메써드를 사용한다.

import itertools

N, M = map(int, input().split())
num_list = [i for i in range(1, N+1)]
    
for num in itertools.product(num_list, repeat = M):
    for i in num:
        print(i, end = ' ')
    print(end = '\n')