Pagini recente » Cod sursa (job #2517610) | Cod sursa (job #2111602) | Cod sursa (job #538695) | Cod sursa (job #111622) | Cod sursa (job #2505039)
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
using namespace std;
const int INF = 2e9;
int n, k;
int f[20];
int sol[20];
void bkt(int x){
if(x == k){
for(int i = 0; i < k; ++i) printf("%d ", sol[i]);
printf("\n");
return;
}
for(int i = sol[x - 1]; i <= n; ++i){
if(f[i]){
sol[x] = i;
f[i]--;
bkt(x + 1);
f[i]++;
}
}
}
int main()
{
freopen("combinari.in", "r", stdin);
freopen("combinari.out", "w", stdout);
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; ++i) f[i] = 1;
bkt(0);
return 0;
}