15651
-
15651) N과 M (3) c++백준코딩일기 2020. 12. 10. 15:41
문제 ) www.acmicpc.net/problem/15651 15651번: N과 M (3) 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해 www.acmicpc.net 풀이 ) 순열을 구했던 15649 번 문제에서 for문안에 if(!visited[i]) 를 제거하면 이 번 문제의 조건을 만족하는 출력값을 얻을 수 있다. 코드 ) #include using namespace std; int N, M; int arr[9]; bool visited[9]; void func(int cnt) { if (cnt == M) { for (int i = 0; i < M; i++)..