Pagini recente » Cod sursa (job #2953521) | Cod sursa (job #146722) | Cod sursa (job #1272380) | Cod sursa (job #1221373) | Cod sursa (job #367583)
Cod sursa(job #367583)
program loto;
uses crt;
var n,i:byte;
sp:longint;
g:boolean;
v,sol:array[1..100]of word;
procedure ext(i:byte;s:longint);
var x,l:byte;
begin
if (s=sp)or(i=7)then
begin
if (s=sp)and(i=7) then
g:=true;
end
else
for x:=1 to n do
if not g then
if s+v[x]<=sp then
begin
sol[i]:=v[x];
ext(i+1,s+v[x]);
end;
end;
begin
readln(n);
readln(sp);
for i:=1 to n do
readln(v[i]);
g:=false;
ext(1,0);
if g then
for i:=1 to 6 do
write(sol[i],' ')
else
writeln(-1);
end.