N과 M(1)

yongju·2022년 12월 8일
0

BAEKJOON

목록 보기
18/40
post-thumbnail

❓문제

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

❗문제 정리

📑코드

import itertools
n,m=map(int, input().split())

numbers=[str(x) for x in range(1,n+1)]

res=list(itertools.permutations(numbers,m))
for i in range(len(res)):
    print(" ".join(res[i]))

📝코드 설명

순서쌍 앞 뒤가 변경되면 다른 쌍이기에 permutations을 써준다.

combinations vs permutations
(4,3)과 (3,4)를 combination에서는 중복으로, permuation에서는 중복이 아닌것으로 간주한다.

🎖제출 결과

💡insight

profile
AI dev

0개의 댓글