Pagini recente » Cod sursa (job #1806162) | Cod sursa (job #676504) | Cod sursa (job #1277585) | Cod sursa (job #2397025) | Cod sursa (job #301948)
Cod sursa(job #301948)
program alex;
var f:text;
a:array[1..150]of longint;
st:array[1..10]of integer;
e,as:boolean;
i,n,k,j,s:longint;
begin
assign(f,'loto.in');reset(f);
readln(f,n,k);
for i:=1 to n do
read(f,a[i]);
close(f);
j:=1;
st[j]:=0;
s:=0;
e:=false;
assign(f,'loto.out');rewrite(f);
while(j>0)and(e=false)do
begin
if st[j]<n then begin
s:=s-a[st[j]];
st[j]:=st[j]+1;
as:=true;
s:=s+a[st[j]];
end
else as:=false;
if as then begin
if j=6 then begin
if s=k then begin
e:=true;
for i:=1 to j do
write(f,a[st[i]],' ');
end;
end
else begin
j:=j+1;
st[j]:=0;
end;
end
else begin
s:=s-a[st[j]];
j:=j-1;
end;
end;
if e=false then writeln(f,-1);
close(f);
end.