Cod sursa(job #856022)

Utilizator DaNutZ2UuUUBB Bora Dan DaNutZ2UuU Data 15 ianuarie 2013 21:46:37
Problema Loto Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

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

int main()
{
    int n, v[101], s;

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

    sort(v + 1, v + n + 1);

    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];
                                return 0;
                            }
                        }
    fout << -1;

    fin.close();
    fout.close();
    return 0;

}