Cod sursa(job #1780647)

Utilizator nedelcu11Nedelcu Mihai Vlad nedelcu11 Data 16 octombrie 2016 14:38:53
Problema Loto Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <fstream>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
int n,s,x[101];
int main()
{   f>>n>>s;
    for(int i=1;i<=n;i++) f>>x[i];
    int w=1;
    for(int i=1;i<=n and w;i++)
        for(int j=1;i<=n and w;j++)
            for(int k=1;k<=n and w;k++)
                for(int l=1;l<=n and w;l++)
                    for(int p=1;p<=n and w;p++)
                        for(int q=1;q<=n and w;q++)
                        {   int sum=x[i]+x[j]+x[k]+x[l]+x[p]+x[q];
                            if(sum==s) {g<<x[i]<<' '<<x[j]<<' '<<x[k]<<' '<<x[l]<<' '<<x[p]<<' '<<x[q]; w=0; }
                        }
    if(w) g<<-1;
    g.close();
    return 0;
}