-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Silver III] Title: N과 M (3), Time: 1792 ms, Memory: 31120 KB -Baekjo…
…onHub
- Loading branch information
1 parent
f15b280
commit c2715db
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import sys | ||
|
||
def dfs(start): | ||
global m, lst | ||
if len(lst) == m: | ||
print(*lst) | ||
else: | ||
for i in range(1, n+1): | ||
lst.append(i) | ||
dfs(i+1) | ||
lst.pop() | ||
|
||
n, m = map(int, sys.stdin.readline().split()) | ||
lst = [] | ||
|
||
dfs(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# [Silver III] N과 M (3) - 15651 | ||
|
||
[문제 링크](https://www.acmicpc.net/problem/15651) | ||
|
||
### 성능 요약 | ||
|
||
메모리: 31120 KB, 시간: 1792 ms | ||
|
||
### 분류 | ||
|
||
백트래킹 | ||
|
||
### 제출 일자 | ||
|
||
2024년 11월 15일 14:06:27 | ||
|
||
### 문제 설명 | ||
|
||
<p>자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오.</p> | ||
|
||
<ul> | ||
<li>1부터 N까지 자연수 중에서 M개를 고른 수열</li> | ||
<li>같은 수를 여러 번 골라도 된다.</li> | ||
</ul> | ||
|
||
### 입력 | ||
|
||
<p>첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 7)</p> | ||
|
||
### 출력 | ||
|
||
<p>한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다.</p> | ||
|
||
<p>수열은 사전 순으로 증가하는 순서로 출력해야 한다.</p> | ||
|