Pagini recente » Cod sursa (job #924970) | Cod sursa (job #2148436) | Cod sursa (job #930200) | Cod sursa (job #1997912) | Cod sursa (job #34117)
Cod sursa(job #34117)
var f,g:text;
i,j,k,l,s,m,n,r:longint;
a:array[1..2000]of longint;
begin
assign(f,'oite.in');
reset(f);
readln(f,n,m);
for i:=1 to n do read(f,a[i]);
for i:=1 to n-3 do begin
s:=a[i];
if s<=m then begin
for j:=i+1 to n-2 do begin
if s+a[j]<=m then begin
s:=s+a[j];
for k:=j+1 to n-1 do begin
if s+a[k]<=m then begin
s:=s+a[k];
for l:=k+1 to n do if s+a[l]=m then r:=r+1;
s:=s-a[k];
end;
end;
s:=s-a[j];
end;
end;
end;
end;
assign(g,'oite.out');
rewrite(g);
write(g,r);
close(g);
end.