Pagini recente » Rating Craciunescu Mihnea Gabriel (mcrg05) | Cod sursa (job #2965963) | Cod sursa (job #155470) | Cod sursa (job #1331154) | Cod sursa (job #794477)
Cod sursa(job #794477)
var c:array[0..500000]of longint; v:array[1..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 (c[i]=0) then inc(s2);
if ((i-b)>0) then if (c[i-b]>0) then dec(v[c[i-b]]);
if i>a then if (c[i-a]>0) then inc(v[c[i-a]]);
if c[i]>0 then s2:=s2+v[c[i]]
end;
end;
assign(output,'divk.out'); rewrite(output); writeln(s2); close(output);
end.