Pagini recente » Cod sursa (job #554564) | Cod sursa (job #1335853) | Cod sursa (job #2433740) | Cod sursa (job #231389) | Cod sursa (job #179632)
Cod sursa(job #179632)
type vect=array[0..100] of longint;
var f:text;
i,l,j,k,n,x,y,m,p,o:integer;
s,s2:longint;
v:vect;
a:vect;
begin
assign(f,'loto.in');
reset(f);
readln(f,n,s);
for i:=0 to n-1 do read(f,v[i]);
l:=0;
for i:=0 to n-1 do
for j:=0 to n-1
do for k:=j to n-1 do begin
a[l]:=v[i]+v[j]+v[k];
inc(l);
end;
k:=1;
for i:=0 to l-1 do
if k=1 then begin
for j:=0 to l-1 do
if k=1 then begin
if s=a[i]+a[j] then k:=0;end
else break
end
else break;
close(f);
assign(f,'loto.out');
rewrite(f);
dec(i);
if k=1 then writeln(f,'-1')
else begin
for k:=0 to n-1 do
if i<>-1 then
for x:=0 to n-1 do
if i<>-1 then
for y:=0 to n-1 do
if i<>-1 then
if a[i]=v[k]+v[x]+v[y] then begin
write(f,v[k],' ',v[x],' ',v[y],' ');
i:=-1;
end;
for k:=0 to n-1 do
if j<>-1 then
for x:=0 to n-1 do
if j<>-1 then
for y:=0 to n-1 do
if j<>-1 then
if a[j]=v[k]+v[x]+v[y] then begin
write(f,v[k],' ',v[x],' ',v[y],' ');
j:=-1;
end;
end;
close(f);
end.