提交时间:2026-01-04 15:40:14
运行 ID: 81154
#include <bits/stdc++.h> using namespace std; int n, r; int ans[10000010]; void print(){ for (int i = 1; i <= r; i++){ cout << setw(3) << ans[i]; } cout << "\n"; return; } void dfs(int step){ if (step == r + 1){ print(); return; } for (int i = ans[step - 1] + 1; i <= n; i++){ ans[step] = i; dfs(step + 1); ans[step] = 0; } } int main(){ scanf("%d%d", &n, &r); dfs(1); return 0; }