Pagini recente » Cod sursa (job #585732) | Cod sursa (job #541895) | Cod sursa (job #2823619) | Cod sursa (job #432070) | Cod sursa (job #46351)
Cod sursa(job #46351)
var f,g:text;
n,s,i,j,p,x:longint;
v:array[1..100] of longint;
{procedure quick(ss,d:integer);
var aux,a,b,ia:integer;
begin
a:=ss; b:=d;
repeat
while v[a]<v[b] do dec(b);
aux:=v[a]; v[a]:=v[b]; v[b]:=aux;
inc(a); ia:=1;
if b>=a then
begin
while v[a]<v[b] do inc(a);
aux:=v[a]; v[a]:=v[b]; v[b]:=aux;
dec(b); ia:=0;
end;
until b<=a;
if s<a-ia then quick(s,a-ia);
if a-ia+1<d then quick(a-ia+1,d);
end;}
begin
assign(f,'loto.in');
reset(f);
readln(f,n,s);
for i:=1 to n do
read(f,v[i]);
close(f);
assign(g,'loto.out');
rewrite(g);
{quick(1,n); }
p:=6;
i:=n;
while(i>0)and(p>0)do
begin
if (s mod v[i]=0)and(s div v[i]=p) then
begin
for j:=1 to p do write(g,v[i],' ');
p:=0; s:=0;
end
else
begin
x:=s div v[i];
if x>p then x:=p-1;
while ((s-x*v[i])div v[1])+x<p do dec(x);
for j:=1 to x do write(g,v[i],' ');
p:=p-x;
s:=s-x*v[i];
end;
dec(i);
end;
if (p<>0)or(s<>0) then begin rewrite(g);writeln(g,'-1') end;
close(g);
end.