Pagini recente » Cod sursa (job #974926) | Cod sursa (job #2202251) | Cod sursa (job #2237575) | Cod sursa (job #2317810) | Cod sursa (job #794522)
Cod sursa(job #794522)
var c:array[0..500000]of longint; v:array[0..500000]of longint;
b1:array[1..1 shl 17]of char;
i,n,k,a,b,t,s,s2:longint;
begin
assign(input,'divk.in'); reset(input); settextbuf(input,b1);
readln(n,k,a,b); s:=0; s2:=0;
for i:=1 to n do
begin
readln(t);
s:=s+t;
c[i]:=s mod k;
if i>=a then
begin
if (i-b-1>=0) then dec(v[c[i-b-1]]);
inc(v[c[i-a]]);
s2:=s2+v[c[i]]
end;
end;
assign(output,'divk.out'); rewrite(output); writeln(s2); close(output);
end.