Cod sursa(job #2326964)

Utilizator StefanZamfirStefan Zamfir StefanZamfir Data 24 ianuarie 2019 12:04:27
Problema Combinari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.32 kb
//#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <set>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <tuple>
#include <fstream>
#include <iomanip>
#include <utility>

#pragma warning "da 100% din tine. :)"
#define nl '\n'
#define cnl cout << '\n';
#define sp ' '
#define pb(x) push_back(x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SIZE 3000
#define NR 105
#define N 1300000
#define INF 10000
#define ll long long
#define ull unsigned ll
#define F "combinari"

using namespace std;
ifstream cin(F".in");
ofstream cout(F".out");

template<class v, class type>
void print(v Vector, type nr) {
    for_each(all(Vector), [](type x) {
        cout << x << ' ';
    });
}

void nimic() {
    return;
}

vector <int> com;
int n, k;
void comb(int pas){
    if(com.size()==k){
        print(com,(int)0);
        cout << nl;
    }
    else for(int i = pas + 1;i<=n;++i){
        com.emplace_back(i);
        comb(i);
        com.pop_back();
    }
}

int main() {
    ios_base::sync_with_stdio(false);
//    freopen("caps.in", "r", stdin);
//    freopen("caps.out", "w", stdout);
    clock_t tStart = clock();
    cin >> n >> k;
    comb(0);
    printf("\nTime taken: %.2fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
}