Created
March 22, 2020 10:57
-
-
Save niklasjang/fdf53e26b64594cca15b878370916ee9 to your computer and use it in GitHub Desktop.
[PS][완전탐색][N자리 K진수]/[BOJ][15651][N과 M (1)]
This file contains 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; | |
int n=0, k=0; | |
bool visited[100]; | |
int arr[100]; | |
void recur(int depth){ | |
if(depth == n){ | |
for(int j=0; j<n; j++){ | |
cout << arr[j] <<' '; | |
} | |
cout<<"\n"; | |
return; | |
} | |
for(int i=1; i<=k; i++){ | |
if(visited[i]) continue; | |
visited[i] = true; | |
arr[depth] = i; | |
recur(depth+1); | |
visited[i] = false; | |
} | |
} | |
int main (void){ | |
cin.tie(NULL); | |
ios::sync_with_stdio("false"); | |
cin>> k>> n; | |
recur(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment