2021-02-07
문제 : https://www.acmicpc.net/problem/15654
15654번: N과 M (5)
N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열
www.acmicpc.net
1. N개의 자연수 중에서 M개를 고른 수열
2. N개의 자연수는 모두 다른 수
2번때문에 입력 따로 받은거 말곤 특별한건 없었음
permutations 사용해서 풀었다
[소스코드]
https://github.com/jisun1125/algorithm-problem-solving/blob/main/baekjoon/no_15654.py
jisun1125/algorithm-problem-solving
Algorithms. Contribute to jisun1125/algorithm-problem-solving development by creating an account on GitHub.
github.com
from itertools import permutations, combinations
n, m = map(int, input().split())
k = list(map(int, input().split()))
P = sorted(permutations(k, m))
for p in P:
for i in p:
print(i, end=' ')
print('')
'PS > 백준' 카테고리의 다른 글
[백준/Python(파이썬)] 15656 N과 M (7) (0) | 2021.02.14 |
---|---|
[백준/Python(파이썬)] 15655 N과 M (6) (0) | 2021.02.14 |
[백준/Python(파이썬)] 15652 N과 M (4) (0) | 2021.02.14 |
[백준/Python(파이썬)] 15651 N과 M (3) (0) | 2021.02.14 |
[백준/Python(파이썬)] 15650 N과 M (2) (0) | 2021.02.14 |