Skip to content

Instantly share code, notes, and snippets.

@niklasjang
Created March 22, 2020 11:15
Show Gist options
  • Save niklasjang/2e1b4c3e66d4828f4f2e2af7a336098e to your computer and use it in GitHub Desktop.
Save niklasjang/2e1b4c3e66d4828f4f2e2af7a336098e to your computer and use it in GitHub Desktop.
[PS][완전탐색][N자리 K진수]/[BOJ][15651][N과 M (4)]
#include <iostream>
using namespace std;
int n=0, k=0;
int arr[100];
void recur(int depth, int start){
if(depth == n){
for(int j=0; j<n; j++){
cout << arr[j] <<' ';
}
cout<<"\n";
return;
}
for(int i=start; i<=k; i++){
arr[depth] = i;
recur(depth+1, i);
}
}
int main (void){
cin.tie(NULL);
ios::sync_with_stdio("false");
cin>> k>> n;
recur(0, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment