Pagini recente » Cod sursa (job #138686) | Cod sursa (job #1938952) | Cod sursa (job #1378912) | Cod sursa (job #163770) | Cod sursa (job #1040880)
#include<fstream>
#include<vector>
#define numaru 666019
using namespace std;
vector <long long> v[numaru];
long long w[100];
ifstream f("loto.in");
ofstream g("loto.out");
bool cauta(long long x)
{
long long unde=x%numaru;
vector <long long> :: iterator i;
for(i=v[unde].begin(); i!=v[unde].end(); ++i)
if(*i==x) return true;
return false;
}
void adauga(long long x)
{
long long unde=x%numaru;
if(cauta(x)==false) v[unde].push_back(x);
}
int main()
{
int n,k,q,p;
long long x,a[2],s[6];
f>>n>>x;
a[0]=x/2;
a[1]=x/2+x%2;
for(k=0;k<n;++k)
{
f>>x;
w[k]=x;
adauga(x);
}
for(k=0;k<2;++k)
{
s[0+3*k]=-1;
for(p=0;p<n;++p)
for(q=0;q<n;++q)
if( a[k] >= w[p] + w[q] && cauta( a[k] - w[p] - w[q] ) )
{
s[0+3*k]=w[p];
s[1+3*k]=w[q];
s[2+3*k]=a[k] - w[p] - w[q];
q=p=n;
}
}
if(s[0]!=-1 && s[3]!=-1)
{
for(k=0;k<6;++k) g<<s[k]<<" ";
g<<"\n";
}
else {g<<"-1\n";for(;;);}
f.close();
g.close();
return 0;
}