Cod sursa(job #2926171)
Utilizator | Andrei Chertes andrei_C1 | Data | 17 octombrie 2022 09:44:34 |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
const int KMAX = 18;
int N, K;
int st[KMAX + 1];
void print(int p) {
for(int i = 1; i <= p; i++) {
fout << st[i] << " ";
}
fout << '\n';
}
void bkt(int p) {
for(int i = st[p - 1] + 1; i <= N; i++) {
st[p] = i;
if(p == K) {
print(p);
} else {
bkt(p + 1);
}
}
}
int main() {
fin >> N >> K;
bkt(1);
fin.close();
fout.close();
return 0;
}