Python3/백준 알고리즘
2022.02.11 [백준] (python 파이썬) N과 M (1)
ian's coding
2022. 2. 11. 01:23
728x90
반응형
https://www.acmicpc.net/problem/15649
15649번: N과 M (1)
한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해
www.acmicpc.net
풀이
이 문제는 순열 문제이다.
1
2
3
4
5
6
|
from itertools import permutations
a,b=list(map(int, input().split()))
arr=[str(i) for i in range(1,a+1)]
for i in list(permutations(arr,b)):
print(" ".join(i))
|
cs |
728x90
반응형