Pagini recente » Pachetul de instalare | Monitorul de evaluare | Diferente pentru propuneri/6-arhiva-educationala intre reviziile 9 si 16 | Statistici Georgescu Mihai (mihaigeorgescu) | Cod sursa (job #3232156)
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef INFOARENA
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
freopen ("combinari.in", "r", stdin);
freopen ("combinari.out", "w", stdout);
#endif
int n, k;
cin >> n >> k;
for (int m = 0; m < (1 << n); m++) {
if (__builtin_popcount(m) == k) {
for (int i = 0; i < n; i++) {
if (m & (1 << i)) {
cout << i + 1 << " ";
}
}
cout << "\n";
}
}
return 0;
}