Pagini recente » football2 | Cod sursa (job #142362) | Cod sursa (job #192741) | Cod sursa (job #72276) | Cod sursa (job #1575679)
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
ofstream g("divk.out");
int R[100005], V[100005], S[100005];
char Buffer[10000000];
int n, k, sol, pos, a, b;
void citeste(int & nr)
{
nr = 0;
while(Buffer[pos] < '0' || Buffer[pos] > '9')
pos++;
while(Buffer[pos] >= '0' && Buffer[pos] <= '9')
nr = nr*10 + Buffer[pos++] - '0';
}
void citire()
{
freopen("divk.in", "r", stdin);
fread(Buffer, 1, 10000000, stdin);
int i;
citeste(n);citeste(k);citeste(a);citeste(b);
for(i=1; i<=n; i++){
citeste(V[i]);
}
}
void dinam()
{
for(int i=1; i<=n; i++){
S[i] = (S[i-1] + V[i]) % k;
if(i >= a)
R[S[i-a+1]]++;
if(i > b)
R[S[i-b]]--;
sol += R[S[i]];
}
g<<sol<<"\n";
}
int main()
{
citire();
dinam();
return 0;
}