Cod sursa(job #3306767)

Utilizator CosminaneBoac Mihai Cosmin Cosminane Data 13 august 2025 15:36:51
Problema Combinari Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
ifstream fin( "combinari.in" );
ofstream fout( "combinari.out" );
vector <int> v;
int n, k;
void dfs( int i, int x ){
	int j;
	/*cout << i << ' ' << x << ':' << ' ';
	for( j = 0; j < v.size(); j++ ){
		cout << v[j] << ' ';
	}
	cout << '\n';*/
	if( i == k - 1 ){
		for( j = 0; j < k; j++ ){
			fout << v[j] << ' ';
		}
		fout << '\n';
	}
	else{
		for( j = x + 1; j + k - 1 - ( i + 1 ) <= n; j++ ){
			v.push_back( j );
			dfs( i + 1, j );
			v.pop_back();
		}
	}
}
int main(){
	fin >> n >> k;
	dfs( -1, 0 );
	return 0;
}