Cod sursa(job #2519800)

Utilizator vlad082002Ciocoiu Vlad vlad082002 Data 8 ianuarie 2020 14:06:20
Problema Loto Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.87 kb
#include <fstream>
using namespace std;

ifstream fin("loto.in");
ofstream fout("loto.out");

int v[128], n, s;
bool found;

void citire() {
    fin >> n >> s;
    for(int i = 1; i <= n; i++)
        fin >> v[i];
}

void solve() {
    for(int a = 1; a <= n; a++)
        for(int b = 1; b <= n; b++)
            for(int c = 1; c <= n; c++)
                for(int d = 1; d <= n; d++)
                    for(int e = 1; e <= n; e++)
                        for(int f = 1; f <= n; f++)
                            if(v[a]+v[b]+v[c]+v[d]+v[e]+v[f] == s) {
                                fout << v[a] << ' ' << v[b] << ' ' << v[c] << ' ' << v[d] << ' ' << v[e] << ' ' << v[f];
                                found = true;
                                return;
                            }
}

int main() {
    citire();
    solve();
    if(!found) fout << -1;
}