Pagini recente » Cod sursa (job #838673) | Cod sursa (job #3276739) | Cod sursa (job #910502) | Cod sursa (job #1356636) | Cod sursa (job #2732731)
#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;
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){
auto test = dic[s-p1.first - p2.first];
if (test.first != 0) {
g << p1.second.first << ' ' << p1.second.second << ' ' << p2.second.first << ' ' << p2.second.second << ' ' << test.first << ' ' << test.second;
return 0;
}
}
g << -1;
return 0;
}