Pagini recente » Cod sursa (job #423802) | Cod sursa (job #1066761) | Cod sursa (job #1049173) | Cod sursa (job #237817) | Cod sursa (job #2116105)
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
typedef struct nod
{
int i,j,k;
} tip;
unordered_map <int,tip> H;
short n;
long s;
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]];
g<<aux.i<<" "<<aux.j<<" "<<aux.k<<" "<<a[i]<<" "<<a[j]<<" "<<a[k];
return 0;
}
}
g<<-1;
return 0;
}