Pagini recente » Cod sursa (job #60924) | Cod sursa (job #1887369) | Cod sursa (job #803635) | Cod sursa (job #2217332) | Cod sursa (job #2892915)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
unordered_map<int, tuple<int, int, int>> loto;
int nrNumere, suma, numere[100];
int main() {
int index1, index2, index3;
unordered_map<int, tuple<int, int, int>>::iterator complement;
fin >> nrNumere >> suma;
for (index1 = 0; index1 < nrNumere; index1 += 1) {
fin >> numere[index1];
}
for (index1 = 0; index1 < nrNumere; index1 += 1) {
for (index2 = index1; index2 < nrNumere; index2 += 1) {
for (index3 = index2; index3 < nrNumere; index3 += 1) {
complement = loto.find(suma - numere[index1] - numere[index2] - numere[index3]);
if (complement != loto.end()) {
fout << numere[index1] << " " << numere[index2] << " " << numere[index3] << " "
<< get<0>(complement->second) << " " << get<1>(complement->second) << " "
<< get<2>(complement->second);
return 0;
}
loto[numere[index1] + numere[index2] + numere[index3]] = make_tuple(numere[index1], numere[index2],
numere[index3]);
}
}
}
fout << -1;
return 0;
}