Pagini recente » Cod sursa (job #1966403) | Cod sursa (job #877346) | Cod sursa (job #2932144) | Cod sursa (job #2897702) | Cod sursa (job #26157)
Cod sursa(job #26157)
var a:array[1..110]of longint;
n,i,j,s,x,l,k,o,p,q:longint;
procedure Sort(l, r: longint);
var
i, j, x, y: longint;
begin
i := l; j := r; x := a[(l+r) DIV 2];
repeat
while a[i] < x do i := i + 1;
while x < a[j] do j := j - 1;
if i <= j then
begin
y := a[i]; a[i] := a[j]; a[j] := y;
i := i + 1; j := j - 1;
end;
until i > j;
if l < j then Sort(l, j);
if i < r then Sort(i, r);
end;
begin
assign(input,'loto.in');
reset(input);
assign(output,'loto.out');
rewrite(output);
readln(n,s);
for i:=1 to n do read(a[i]);
sort(1,n);
q:=0;
for i:=1 to n do
begin
for j:=i to n do
begin
for l:=j to n do
begin
for k:=l to n do
begin
for o:=k to n do
begin
for p:=o to n do
begin
if a[i]+a[j]+a[l]+a[k]+a[o]+a[p]=s then
begin
q:=1;
writeln(a[i],' ',a[j],' ',a[l],' ',a[k],' ',a[o],' ',a[p]);
end;
end;
if q=1 then break;
end;
if q=1 then break;
end;
if q=1 then break;
end;
if q=1 then break;
end;
if q=1 then break;
end;
if q=0 then writeln(-1);
close(output);
end.