Pagini recente » Cod sursa (job #813740) | Cod sursa (job #1194556) | Cod sursa (job #805110) | Cod sursa (job #3211640) | Cod sursa (job #2748098)
#include <bits/stdc++.h>
#define mod 99983
using namespace std;
struct loto
{
int x, y, z, val;
};
vector <loto> v[mod];
int nr[105], n, s, i, sum, j, k;
int main()
{
ifstream f("loto.in");
ofstream g("loto.out");
f >> n >> s;
for(i = 1; i <= n; i++)
f >> nr[i];
for(i = 1; i <= n; i++)
for(j = i; j <= n; j++)
for(k = j; k <= n; k++)
{
sum = nr[i] + nr[j] + nr[k];
v[sum % mod].push_back({nr[i], nr[j], nr[k], sum});
}
for(i = 0; i < mod; i++)
{
for(j = 0; j < v[i].size(); j++)
{
sum = s - v[i][j].val;
if(sum >= 0)
{
for(k = 0; k < v[sum % mod].size(); k++)
{
if(v[sum % mod][k].val == sum)
{
g << v[i][j].x << " " << v[i][j].y << " " << v[i][j].z << " " << v[sum % mod][k].x << " " << v[sum % mod][k].y << " " << v[sum % mod][k].z;
return 0;
}
}
}
}
}
g << -1;
return 0;
}