(백준) 15656 – N and M (7) (Python)

질문

15656: N과 M (7) (acmicpc.net)

설명하다

product는 반복이나 순서에 구애받지 않는 정말 자유로운(?) 순열입니다.

특히 시퀀스에서 선택할 자릿수인 repeat라는 매개변수를 사용합니다.

from sys import stdin
from itertools import product
input = lambda : stdin.readline().strip()

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
new_A = product(A, repeat = M)

for i in new_A :
    print(*i)

error: Alert: Content selection is disabled!!