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
- DirectX11
- Programmers
- Unreal Engine5
- GeeksForGeeks
- Frustum
- winapi
- 팰린드롬 만들기
- 2294
- softeer
- TObjectPtr
- 프로그래머스
- const
- 줄 세우기
- NRVO
- RootMotion
- 티스토리챌린지
- C
- UE5
- 언리얼엔진5
- UnrealEngine5
- UnrealEngine4
- directx
- IFileDialog
- algorithm
- RVO
- C++
- 1563
- baekjoon
- 백준
- 오블완
Archives
- Today
- Total
Game Develop
[Algorithm] Baekjoon 15651번 : N과 M (3) 본문
https://www.acmicpc.net/problem/15651
15651번: N과 M (3)
한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해
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
|
int n, m;
vector<int> v;
void DFS()
{
if (v.size() == m)
{
for (int i = 0; i < m; ++i)
{
printf("%d ", v[i]);
}
printf("\n");
return;
}
for (int i = 1; i <= n; ++i)
{
v.push_back(i);
DFS();
v.pop_back();
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; ++i)
{
v.push_back(i);
DFS();
v.pop_back();
}
}
|
cs |
최대 n까지의 숫자범위내에서 m개를 중복허용하게 뽑는 문제.
무조건 1부터 뽑는거라 딱히 매개변수로 뭔갈 넘기거나 할 필요가 없다.
'Algorithm > Baekjoon' 카테고리의 다른 글
[Algorithm] Baekjoon 15655번 : N과 M (7) (0) | 2023.05.01 |
---|---|
[Algorithm] Baekjoon 15655번 : N과 M (6) (0) | 2023.05.01 |
[Algorithm] Baekjoon 1806번 : 부분합 (0) | 2023.04.30 |
[Algorithm] Baekjoon 2230번 : 수 고르기 (0) | 2023.04.30 |
[Algorithm] Baekjoon 11048번 : 이동하기 (0) | 2023.04.30 |