Pagini recente » Cod sursa (job #2650344) | Cod sursa (job #2902566) | Cod sursa (job #2184893) | Cod sursa (job #932684) | Cod sursa (job #2116129)
#include <fstream>
#include <unordered_map>
#include <algorithm>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
typedef struct nod
{
unsigned long i,j,k;
} tip;
unordered_map <unsigned long,tip> H;
short n;
long s;
unsigned long v[7];
unsigned long a[101];
int main()
{
int i,j,k;
f>>n>>s;
for(int x=1; x<=n; x++)
f>>a[x];
tip aux;
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
for(k=1; k<=n; k++)
{
aux.i=i;
aux.j=j;
aux.k=k;
H[a[i]+a[j]+a[k]]=aux;
if(H.count(s-a[i]-a[j]-a[k])>0)
{
aux=H[s-a[i]-a[j]-a[k]];
v[1]=aux.i;
v[2]=aux.j;
v[3]=aux.k;
v[4]=a[i];
v[5]=a[j];
v[6]=a[k];
sort(v+1,v+7);
for(int d=1;d<=6;d++)
g<<v[d]<<" ";
return 0;
}
}
g<<-1;
return 0;
}