Pagini recente » Cod sursa (job #2662345) | Cod sursa (job #945379) | Cod sursa (job #2157623) | Cod sursa (job #3144018) | Cod sursa (job #2602911)
#include <stdio.h>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 0x3f3f3f3f;
ifstream fin ("combinari.in");
ofstream fout ("combinari.out");
int N, k, d[20];
void write() {
rep(i,k) { fout << d[i] << ' '; } fout << '\n';
}
void combinari(int pos, int lvl) {
if (lvl == k) {
write();
return;
}
if (k - lvl == N - pos) {
for(int j = lvl, i = pos; j < k; j++, i++) {
d[j] = i+1;
}
write();
return;
}
for(int i = pos; i < N; i++) {
d[lvl] = i+1;
combinari(i+1, lvl+1);
}
}
int main(void) {
// freopen("combinari.in", "r", stdin);
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
fin >> N >> k;
combinari(0, 0);
return 0;
}