Pagini recente » Cod sursa (job #1773162) | Cod sursa (job #252753) | Cod sursa (job #1598645) | Cod sursa (job #1680698) | Cod sursa (job #570008)
Cod sursa(job #570008)
var a,v:array[1..100] of longint;
n,i:integer;
s,nmax,nmin:longint;
f1,f2:text;
b:boolean;
{
procedure loto(p,j:integer; s1:longint);
var i:integer;
begin
if p>6 then begin
if s1=s then
begin
for i:=1 to 6 do
write(f2,v[i],' ');
close(f2);
halt;
end
end
else
for i:=j to n do
begin
v[p]:=a[i];
loto(p+1,i,s1+a[i]);
end;
end; }
function min(a,b:integer):integer;
begin
if a>b then min:=b else min:=a;
end;
procedure loto(p,t:integer; s1:longint);
var i,j:integer;
begin
if {(p>n)or}(t=6) then begin
if s1=s then
begin
for i:=1 to n do
for j:=1 to v[i] do
write(f2,a[i],' ');
close(f2);
halt;
end
end
else if p<=n then
for i:=0 to min(6,s div a[p]) do
begin
v[p]:=i;
loto(p+1,t+i,s1+i*a[p]);
v[p]:=0;
end;
end;
begin
assign(f1,'loto.in');
assign(f2,'loto.out');
reset(f1);
rewrite(f2);
readln(f1,n,s);
for i:=1 to n do
read(f1,a[i]);
nmax:=a[1];
nmin:=a[1];
for i:=2 to n do
begin
if a[i]<nmin then nmin:=a[i];
if a[i]>nmax then nmax:=a[i];
end;
if (s<=nmax*6)and(s>=nmin*6) then
loto(1,0,0);
writeln(f2,-1);
close(f2);
end.