문제 링크입니다: https://www.acmicpc.net/status?user_id=jaimemin&problem_id=15651&from_mine=1
채점 현황
www.acmicpc.net
간단한 백트래킹 문제였습니다.
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
const int MAX = 7; | |
int N, M; | |
int arr[MAX]; | |
void func(int idx) | |
{ | |
if (idx == M) | |
{ | |
for (int i = 0; i < M; i++) | |
{ | |
cout << arr[i] << " "; | |
} | |
cout << "\n"; | |
return; | |
} | |
for (int i = 1; i <= N; i++) | |
{ | |
arr[idx] = i; | |
func(idx + 1); | |
} | |
} | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
cin >> N >> M; | |
func(0); | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 15655번 N과 M (6) (2) | 2019.08.28 |
---|---|
백준 15654번 N과 M (5) (0) | 2019.08.25 |
백준 15650번 N과 M(2) (2) | 2019.08.21 |
백준 2775번 부녀회장이 될테야 (0) | 2019.08.11 |
백준 2981번 검문 (6) | 2019.08.08 |