Pagini recente » Cod sursa (job #1151623) | Cod sursa (job #2380536) | Cod sursa (job #2404692) | Cod sursa (job #471412) | Cod sursa (job #2116119)
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
typedef struct nod
{
int i,j,k;
}tip;
unsigned long n,s,ii,jj,kk,a[1000];
int main()
{f>>n>>s;
for(ii=1;ii<=n;ii++)
f>>a[ii];
unordered_map<unsigned long,tip> H;
tip aux;
for(ii=1;ii<=n;ii++)
for(jj=1;jj<=n;jj++)
for(kk=1;kk<=n;kk++)
{
aux.i=ii;
aux.j=jj;
aux.k=kk;
H[a[ii]+a[jj]+a[kk]]=aux;
if(H.count(s-a[ii]-a[jj]-a[kk])>0){aux=H[s-a[ii]-a[jj]-a[kk]];
g<<aux.i<<" "<<aux.j<<" "<<aux.k<<" "<<a[ii]<<" "<<a[jj]<<" "<<a[kk];return 0;}
}
g<<-1;
return 0;
}