Cod sursa(job #3128976)

Utilizator RealDream21Fabian-Andrei RealDream21 Data 11 mai 2023 20:01:11
Problema Loto Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.92 kb
#include <iostream>
#include <fstream>
#include <map>

using namespace std;


int main()
{
    ifstream fin("loto.in");
    ofstream fout("loto.out");
    int n, s, v[105];
    bool found = false;
    fin >> n >> s;
    for(int i = 0; i < n; i++)
        fin >> v[i];

    for(int i = 0; i < n && !found; i++)
        for(int j = 0; j < n && !found; j++)
            for(int k = 0; k < n && !found; k++)
                for(int l = 0; l < n && !found; l++)
                    for(int q = 0; q < n && !found; q++)
                        for(int w = 0; w < n && !found; w++)
                            if(v[i] + v[j] + v[k] + v[l] + v[q] + v[w] == s){
                                fout << v[i] << " " << v[j] << " "<< v[k] << " " << v[l] << " " << v[q] << " " << v[w];
                                found = true;
                            }
    if(found == false)
        fout << -1;
    return 0;
}