Cod sursa(job #1342181)

Utilizator redducks100Andronache Simone redducks100 Data 13 februarie 2015 16:54:27
Problema Loto Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.81 kb
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

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

int n;
unsigned long long S,v[101];

void rez()
{
     for(int i=0;i<n;i++)
        for(int z=0;z<n;z++)
            for(int x=0;x<n;x++)
                for(int c=0;c<n;c++)
                    for(int r=0;r<n;r++)
                        for(int b=0;b<n;b++)
                            if(v[i]+v[z]+v[x]+v[c]+v[r]+v[b]==S)
                            {
                                g<<v[i]<<" "<<v[z]<<" "<<v[x]<<" "<<v[c]<<" "<<v[r]<<" "<<v[b]<<"\n";
                                return;
                            }
        g<<"-1"<<"\n";
}

int main()
{
    f>>n>>S;
    for(int i=0;i<n;i++)
        f>>v[i];
    sort(v,v+n);
    rez();

    return 0;
}