You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
414 B
21 lines
414 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int n, m;
|
|
void dfs(int u, string s,int pre ){
|
|
if(u==m+1){
|
|
cout << s << endl;
|
|
return;
|
|
}
|
|
for (int i = pre+1; i <=n ; i++){
|
|
if(s=="")
|
|
dfs(u + 1, to_string(i), i);
|
|
else
|
|
dfs(u + 1, s + " " + to_string(i), i);
|
|
}
|
|
}
|
|
int main() {
|
|
cin >> n >> m;
|
|
dfs(1, "", 0);
|
|
return 0;
|
|
} |