mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P1157 组合的输出
R39032040
This commit is contained in:
parent
9cfc6a041d
commit
24420a36f5
34
problem/P1157/P1157.cpp
Normal file
34
problem/P1157/P1157.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// R39032040
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, m;
|
||||
int num[105];
|
||||
bool vis[105];
|
||||
|
||||
void dfs(int k) {
|
||||
if (k == n + 1) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
cout << setw(3) << num[j];
|
||||
}
|
||||
cout << endl;
|
||||
return;
|
||||
}
|
||||
for (int i = num[k - 1]; i <= m; i++) {
|
||||
if (!vis[i]) {
|
||||
num[k] = i;
|
||||
vis[i] = true;
|
||||
dfs(k + 1);
|
||||
vis[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> m >> n;
|
||||
num[0] = 1;
|
||||
dfs(1);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user