Cod sursa(job #1588091)

Utilizator leopop29Pop Leonard leopop29 Data 2 februarie 2016 19:51:36
Problema Submultimi Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include <iostream>
#include <fstream>
#include <bitset>

using namespace std;

ifstream f("submultimi.in");
ofstream g("submultimi.out");

bitset<17> nr;
int n, k, v[17];

void bk(int x)
{
    if(x > k)
    {
        for(int i = 1; i <= k; ++i)
            g << v[i] << ' ';
        g << '\n';
    }
    else
        for(int i = v[x-1]+1; i <= n; ++i)
        {
            nr[x] = 1;
            v[x] = i;
            bk(x+1);
            nr[x] = 0;
        }
}

int main()
{
    f >> n;

    for(int i = 1; i <= n; ++i)
    {
        k = i;
        bk(1);
    }
    return 0;
}