Mai intai trebuie sa te autentifici.
Cod sursa(job #515944)
| Utilizator | Data | 22 decembrie 2010 19:03:25 | |
|---|---|---|---|
| Problema | Divk | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
const f='divk.in';g='divk.out';
var
n,k,a,b,i:longint;
rez:extended;
v,s,c:array[0..500001] of longint;
buf:array[1..1 shl 20] of char;
buf1:array[1..1 shl 15] of char;
begin
assign(input,f);reset(input);
assign(output,g);rewrite(output);
settextbuf(output,buf1);
settextbuf(input,buf);
readln(n,k,a,b);
for i:=1 to n do
begin
readln(v[i]);
s[i]:=(s[i-1]+v[i])mod k;
end;
for i:=a to n do
begin
inc(c[s[i-a]]);
if i>b then c[s[i-b-1]]:=c[s[i-b-1]]-1;
rez:=rez + c[s[i]];
end;
write(rez);
close(input);close(output);
end.
