Pagini recente » Cod sursa (job #1886738) | Cod sursa (job #1290434) | Cod sursa (job #2783452) | Cod sursa (job #2731851) | Cod sursa (job #2201770)
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <vector>
#define LIM 1<<17
/// TONI BO$$ was here
/// #MLC
using namespace std;
char BUF[LIM];
int poz;
inline char getChar(){
poz++;
if(poz>=LIM){
fread(BUF,LIM,1,stdin);
poz=0;
}
return BUF[poz];
}
inline int getNr(){
int r=0, semn=1;
char ch=getChar();
while(isdigit(ch)==0 && ch!='-') ch=getChar();
if(ch=='-'){
semn=-1;
ch=getChar();
}
while(isdigit(ch)!=0){
r=r*10+semn*(ch-'0');
ch=getChar();
}
return r;
}
int v[500001],s[100001];
int main()
{
int n,k,a,b,i;
long long rez=0;
freopen("divk.in","r",stdin);
freopen("divk.out","w",stdout);
n=getNr();
k=getNr();
a=getNr();
b=getNr();
for(i=1; i<=n; i++)
v[i]=getNr();
for(i=1; i<=n; i++)
v[i]=(v[i]+v[i-1])%k;
rez=0;
for(i=1; i<=n; i++)
{
if(i>=a)
s[v[i-a]]++;
if(i>=b+1)
s[v[i-b-1]]--;
rez+=s[v[i]];
}
printf("%lld",rez);
return 0;
}