File tree Expand file tree Collapse file tree
백준/Silver/15650. N과 M (2) Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # 15650 N과 M (2)
2+ # 실버 3
3+
4+ import sys
5+ input = sys .stdin .readline
6+
7+ from itertools import combinations
8+
9+ # 1부터 N까지 자연수 중 길이가 M인 수열
10+ N , M = map (int , input ().split ())
11+
12+ # [1, 2, 3, 4]
13+ num = [i for i in range (1 , N + 1 )]
14+
15+ for i in combinations (num , M ):
16+ print (* i )
Original file line number Diff line number Diff line change 1+ # [ Silver III] N과 M (2) - 15650
2+
3+ [ 문제 링크] ( https://www.acmicpc.net/problem/15650 )
4+
5+ ### 성능 요약
6+
7+ 메모리: 32412 KB, 시간: 32 ms
8+
9+ ### 분류
10+
11+ 백트래킹
12+
13+ ### 제출 일자
14+
15+ 2025년 6월 1일 20:43:31
16+
17+ ### 문제 설명
18+
19+ <p >자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오.</p >
20+
21+ <ul >
22+ <li>1부터 N까지 자연수 중에서 중복 없이 M개를 고른 수열</li>
23+ <li>고른 수열은 오름차순이어야 한다.</li>
24+ </ul >
25+
26+ ### 입력
27+
28+ <p >첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8)</p >
29+
30+ ### 출력
31+
32+ <p >한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다.</p >
33+
34+ <p >수열은 사전 순으로 증가하는 순서로 출력해야 한다.</p >
35+
You can’t perform that action at this time.
0 commit comments