Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- NRVO
- DirectX11
- 줄 세우기
- Frustum
- 1563
- 티스토리챌린지
- const
- 언리얼엔진5
- Unreal Engine5
- Programmers
- RVO
- 프로그래머스
- C
- UnrealEngine5
- UE5
- baekjoon
- 오블완
- 백준
- winapi
- 팰린드롬 만들기
- 2294
- softeer
- GeeksForGeeks
- UnrealEngine4
- RootMotion
- C++
- algorithm
- IFileDialog
- directx
- TObjectPtr
Archives
- Today
- Total
Game Develop
[Algorithm] Baekjoon 15655번 : N과 M (7) 본문
https://www.acmicpc.net/problem/15656
15656번: N과 M (7)
N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
int n, m;
vector<int> nums;
vector<int> v;
void DFS(int curIndex)
{
if (v.size() == m)
{
for (int i = 0; i < m; ++i)
{
printf("%d ", v[i]);
}
printf("\n");
return;
}
for (int i = 0; i < n; ++i)
{
v.push_back(nums[i]);
DFS(i);
v.pop_back();
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 0; i < n; ++i)
{
int temp = 0;
cin >> temp;
nums.push_back(temp);
}
sort(nums.begin(), nums.end());
for (int i = 0; i < n; ++i)
{
v.push_back(nums[i]);
DFS(i);
v.pop_back();
}
}
|
cs |
출력 시에 사전순으로 출력해야 한다는것만 인지하자.
'Algorithm > Baekjoon' 카테고리의 다른 글
[Algorithm] Baekjoon 15665번 : N과 M (11) (0) | 2023.05.01 |
---|---|
[Algorithm] Baekjoon 15664번 : N과 M (10) (0) | 2023.05.01 |
[Algorithm] Baekjoon 15655번 : N과 M (6) (0) | 2023.05.01 |
[Algorithm] Baekjoon 15651번 : N과 M (3) (0) | 2023.05.01 |
[Algorithm] Baekjoon 1806번 : 부분합 (0) | 2023.04.30 |