Cod sursa(job #2474028)

Utilizator ValentinSavoiuFMI Savoiu Valentin-Marian ValentinSavoiu Data 14 octombrie 2019 17:21:00
Problema Combinari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
#include <bits/stdc++.h>
#define pii pair<int, int>
#define pb push_back

#define NMAX 7003
using namespace std;
ifstream f("combinari.in");
ofstream g("combinari.out");
int N, K, st[22];
void bkt (int k) {
    if (k == K + 1) {
        for (int j = 1; j <= K; ++j)
            g << st[j] << ' ';
        g << '\n';
    }
    for (int i = st[k - 1] + 1; i <= N; ++i) {
        st[k] = i;
        bkt(k + 1);
    }
}
int main() {
    f >> N >> K;
    st[0] = 0;
    bkt(1);
    return 0;
}