Cod sursa(job #153534)

Utilizator bogdan2412Bogdan-Cristian Tataroiu bogdan2412 Data 10 martie 2008 16:37:53
Problema Combinari Scor 90
Compilator cpp Status done
Runda Arhiva educationala Marime 1.13 kb
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <list>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

//PRE-WRITTEN CODE - LOOK DOWN FOR SOLUTION

typedef long long LL;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define FORI(it, v) for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it) 
#define pb push_back
#define mp make_pair
#define CLR(v, sz) { (v).clear(); (v).resize( (sz) ); }
#define SET(v, sz, value) { (v).clear(); (v).resize( (sz), (value) ); }

#define ISS istringstream
template<class T> string toStr(T a) { ostringstream S; S << a; return S.str(); }

int N, K;
int st[20];

void back( int k, int Max, string rez )
{
	if (k == K)
	{
		printf("%s\n", rez.c_str());
		return;
	}

	for (int i = Max + 1; i <= N - K + k + 1; i++)
		back( k + 1, i, rez + toStr(i) + " ");
}

int main()
{
	freopen("combinari.in", "rt", stdin);
	freopen("combinari.out", "wt", stdout);

	scanf("%d %d", &N, &K);
	back(0, 0, "");

	return 0;
}