[Silver II] Title: N과 M (9), Time: 104 ms, Memory: 39152 KB -BaekjoonHub
This commit is contained in:
19
백준/Silver/15663. N과 M (9)/N과 M (9).py
Normal file
19
백준/Silver/15663. N과 M (9)/N과 M (9).py
Normal file
@@ -0,0 +1,19 @@
|
||||
from itertools import combinations
|
||||
import sys
|
||||
from itertools import permutations
|
||||
from itertools import product
|
||||
import math
|
||||
|
||||
input = sys.stdin.readline
|
||||
|
||||
result = set()
|
||||
n, m = map(int, input().split())
|
||||
a = list(map(int,input().split()))
|
||||
a = sorted(a)
|
||||
for i in permutations(a, m):
|
||||
result.add((i))
|
||||
|
||||
result = sorted(result)
|
||||
|
||||
for i in result:
|
||||
print(*i)
|
||||
36
백준/Silver/15663. N과 M (9)/README.md
Normal file
36
백준/Silver/15663. N과 M (9)/README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# [Silver II] N과 M (9) - 15663
|
||||
|
||||
[문제 링크](https://www.acmicpc.net/problem/15663)
|
||||
|
||||
### 성능 요약
|
||||
|
||||
메모리: 39152 KB, 시간: 104 ms
|
||||
|
||||
### 분류
|
||||
|
||||
백트래킹
|
||||
|
||||
### 제출 일자
|
||||
|
||||
2025년 3월 1일 21:24:53
|
||||
|
||||
### 문제 설명
|
||||
|
||||
<p>N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오.</p>
|
||||
|
||||
<ul>
|
||||
<li>N개의 자연수 중에서 M개를 고른 수열</li>
|
||||
</ul>
|
||||
|
||||
### 입력
|
||||
|
||||
<p>첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8)</p>
|
||||
|
||||
<p>둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다.</p>
|
||||
|
||||
### 출력
|
||||
|
||||
<p>한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다.</p>
|
||||
|
||||
<p>수열은 사전 순으로 증가하는 순서로 출력해야 한다.</p>
|
||||
|
||||
Reference in New Issue
Block a user