Cod sursa(job #2573078)

Utilizator BogdanRazvanBogdan Razvan BogdanRazvan Data 5 martie 2020 15:43:48
Problema Combinari Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin ("combinari.in);
ofstream fout ("combinari.out");

void usain_bolt()
{
    ios::sync_with_stdio(false);
    fin.tie(0);
}

const int N = 20;

int n, m, ans[N];

void solve(int k)
{
    for(int i = ans[k - 1] + 1; i <= n; ++i) {
        ans[k] = i;
        if(k < m) solve(k + 1);
        else {
            for(int j = 1; j <= m; ++j) fout << ans[j] << " ";
            fout << "\n";
        }
    }
}

int main()
{
    usain_bolt();

    fin >> n >> m;
    solve(1);

    return 0;
}