Pagini recente » Cod sursa (job #1542696) | Cod sursa (job #2730117) | Cod sursa (job #2652297) | Cod sursa (job #2557871) | Cod sursa (job #1493073)
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <map>
using namespace std;
struct num
{
long long int s, x, y, z;
} aux;
int main()
{
map<long long int, struct num> h;
long long int i, j, k, s, n, a[100];
freopen("loto.in", "r", stdin);
freopen("loto.out", "w", stdout);
scanf("%lld %lld", &n, &s);
for (i = 0; i < n; i++)
{
scanf("%lld", &a[i]);
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
for (k = 0; k < n; k++)
{
aux.s = a[i]+a[j]+a[k];
aux.x = a[i];
aux.y = a[j];
aux.z = a[k];
h[aux.s] = aux;
if(h[s-aux.s].s == s - aux.s)
{
printf("%lld %lld %lld %lld %lld %lld", a[i], a[j], a[k], h[s-aux.s].x, h[s-aux.s].y, h[s-aux.s].z);
goto label;
}
}
printf("-1");
label:
return 0;
}