Pagini recente » Cod sursa (job #547701) | Cod sursa (job #324991) | Cod sursa (job #277701) | Cod sursa (job #2722858) | Cod sursa (job #1040895)
#include<fstream>
#include<vector>
#define numaru 666019
using namespace std;
vector <long long> v[numaru];
long long z[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,w,e,r,t;
long long x,s;
f>>n>>s;
for(k=0;k<n;++k)
{
f>>x;
z[k]=x;
adauga(x);
}
for(q=0;q<n;++q)
if(s>=z[q])
for(w=0;w<n;++w)
if(s>=z[q]+z[w])
for(e=0;e<n;++e)
if(s>=z[q]+z[w]+z[e])
for(r=0;r<n;++r)
if(s>=z[q]+z[w]+z[e]+z[r])
for(t=0;t<n;++t)
if(s>=z[q]+z[w]+z[e]+z[r]+z[t] && cauta(s-(z[q]+z[w]+z[e]+z[r]+z[t])))
{
g<<z[q]<<" "<<z[w]<<" "<<z[e]<<" "<<z[r]<<" "<<z[t]<<" "<<s-(z[q]+z[w]+z[e]+z[r]+z[t])<<"\n";
f.close();
g.close();
return 0;
}
g<<"-1\n";
f.close();
g.close();
return 0;
}