Cod sursa(job #1415363)

Utilizator andrei124Andrei Roman andrei124 Data 4 aprilie 2015 14:20:23
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include<iostream>
using namespace std;
int v[101];
int main()
{
    int n,i,cnt=0,s,a,b,c,d,e,f;
    cin>>n>>s;
    for(i=1;i<=n;i++)cin>>v[i];
    for(a=1;a<=n;a++)
        for(b=1;b<=n;b++)
          for(c=1;c<=n;c++)
            for(d=1;d<=n;d++)
              for(e=1;e<=n;e++)
                for(f=1;f<=n;f++)
                    if(v[a]+v[b]+v[c]+v[d]+v[e]+v[f]==s)
    {
        cnt=1;
        cout<<v[a]<<" "<<v[b]<<" "<<v[c]<<" "<<v[d]<<" "<<v[e]<<" "<<v[f];
        return 0;
    }

    if(cnt==0)cout<<-1;
    return 0;
}