Cod sursa(job #1717598)
Utilizator | Data | 15 iunie 2016 11:58:17 | |
---|---|---|---|
Problema | Combinari | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
using namespace std;
ifstream in ("combinari.in");
ofstream out ("combinari.out");
int i,n,k,j,x,nr,l;
int main()
{
in>>n>>k;
nr=0;
for(i=1; i<(1<<n); i++)
{
x=i; nr=0;
for(j=1; j<=n; j++)
{
if(x%2==1) nr++;
x/=2;
}
if(nr==k) {
x=i;
for(j=1; j<=n; j++)
{
if(x%2==1) out<<j<<" ";
x/=2;
}
out<<'\n';}
}
return 0;
}