Cod sursa(job #2211189)
| Utilizator | Data | 9 iunie 2018 15:26:54 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int n, gk;
vector<int> solution;
void solve(int k, int p) {
if (solution.size() == gk) {
for (auto x : solution) {
printf("%d ", x + 1);
}
printf("\n");
return;
}
for (int i = p; i < n; ++i) {
solution.push_back(i);
solve(k - 1, i + 1);
solution.pop_back();
}
}
int main() {
freopen("combinari.in", "r", stdin);
freopen("combinari.out", "w", stdout);
scanf("%d %d", &n, &gk);
solve(gk, 0);
return 0;
}
