[BOJ] 15651번 : N과 M (3)
2024. 8. 18. 08:00ㆍAlgorithm
1. problem :
https://www.acmicpc.net/problem/15651
2. solution 1:
#include <bits/stdc++.h>
using namespace std;
int N, M;
int ans[8];
void backTrack(int k) {
if (k == M) {
for (int i = 0; i < M; i++) cout << ans[i] << ' ';
cout << '\n';
return;
}
for (int i = 0; i < N; i++) {
ans[k] = i + 1;
backTrack(k + 1);
}
}
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N >> M;
backTrack(0);
}
'Algorithm' 카테고리의 다른 글
[BOJ] 15654번 : N과 M (5) (0) | 2024.08.18 |
---|---|
[BOJ] 15652번 : N과 M (4) (0) | 2024.08.18 |
[BOJ] 15650번 : N과 M (2) (0) | 2024.08.18 |
[C++] next_permutation (0) | 2024.08.17 |
[BOJ] 9663번 : N-Queen (0) | 2024.08.17 |