Pagini recente » Cod sursa (job #356936) | Cod sursa (job #2468976) | Cod sursa (job #1308759) | Cod sursa (job #164112) | Cod sursa (job #2024936)
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
ifstream fin ("combinari.in");
ofstream fout ("combinari.out");
int n, k;
fin >> n >> k;
int putere = (1<<n)-1;
for (int i = putere; i>=0; --i)
{
if (__builtin_popcount(i) != k) continue;
for (int j = n-1; j>=0; --j)
if (i & (1<<j))
fout << n-j << " ";
fout << '\n';
}
return 0;
}