Pagini recente » Cod sursa (job #1416869) | Cod sursa (job #2858020) | Cod sursa (job #1198941) | Cod sursa (job #933589) | Cod sursa (job #2894871)
#include <bits/stdc++.h>
using namespace std;
ifstream in("loto.in");
ofstream out("loto.out");
struct perechi{
int x, y, z;
};
unordered_map <int, perechi> loterie;
int nrLoterie, Suma, v[101], ok = 0;
int main() {
in >> nrLoterie >> Suma;
for (int i = 0; i < nrLoterie; i++)
in >> v[i];
for (int i = 0; i < nrLoterie; i++)
for (int j = i; j < nrLoterie;j ++)
for (int k = j; k < nrLoterie; k++)
{
perechi numar;
numar.x = v[i];
numar.y = v[j];
numar.z = v[k];
loterie.insert(make_pair(v[i] + v[j] + v[k], numar));
}
for (int i = 0; i < nrLoterie; i++)
for (int j = i; j < nrLoterie; j++)
for (int k = j; k < nrLoterie; k++)
if (loterie.find(Suma - (v[i] + v[j] + v[k])) != loterie.end())
{
ok = 1;
out << loterie[Suma - v[i] - v[j] - v[k]].x << " " << loterie[Suma - v[i] - v[j] - v[k]].y << " " << loterie[Suma - v[i] - v[j] - v[k]].z << " " <<
loterie[v[i] + v[j] + v[k]].x << " " << loterie[v[i] + v[j] + v[k]].y << " " << loterie[v[i] + v[j] + v[k]].z;
return 0;
}
if (ok == 0)
out << -1;
return 0;
}