Pagini recente » Cod sursa (job #2594274) | Cod sursa (job #2504178) | Cod sursa (job #2442704) | Cod sursa (job #838710) | Cod sursa (job #2732701)
#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream f ("loto.in");
ofstream g ("loto.out");
unordered_map<int,pair<int,int>> dic;
int v[100];
int main()
{
int n, s, nr;
f >> n >> s;
for (int i = 0; i < n; i++)
f >> v[i];
for (int i = 0; i < n;i ++)
for (int j = 0; j < n; j++)
dic[v[i]+v[j]] = {v[i],v[j]};
for (auto p1: dic)
for (auto p2:dic)
for (auto p3:dic)
if (p1.first + p2.first + p3.first == s) {
g << p1.second.first << ' ' << p1.second.second << ' ' << p2.second.first << ' ' << p2.second.second << ' ' << p3.second.first << ' ' << p3.second.second;
return 0;
}
g << -1;
return 0;
}