Pagini recente » Cod sursa (job #2529367) | Cod sursa (job #1146086) | Cod sursa (job #2041335) | Cod sursa (job #2189889) | Cod sursa (job #2743678)
#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
struct elemente
{
int a, b, c;
};
unordered_map <int, elemente> hashh;
int v[101];
int main()
{
bool ok = false;
int n, s,a,suma=0,index=0;
fin >> n >> s;
for (int i = 0; i < n; i++)
{
fin >> a;
cout << a << ' ';
v[index++] = a;
}
for (int i = 0; i < n; i++)
{
for (int j = i; j < n; j++)
{
for (int k = j; k < n; k++)
{
suma = v[i] + v[j] + v[k];
elemente ob;
ob.a = v[i];
ob.b = v[j];
ob.c = v[k];
hashh[suma] = ob;
}
}
}
for (auto it : hashh)
{
if (hashh.find(s - it.first) != hashh.end())
{
fout << hashh[s - it.first].a << ' ' << hashh[s - it.first].b << ' ' << hashh[s - it.first].c << ' ' << it.second.a << ' ' << it.second.b << ' ' << it.second.c;
ok = true;
break;
}
}
if (ok == false)
{
fout << -1;
}
return 0;
}