Pagini recente » Cod sursa (job #1312297) | Cod sursa (job #3293961) | Cod sursa (job #896461) | Cod sursa (job #85022) | Cod sursa (job #2640215)
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
ifstream fin("divk.in");
ofstream fout("divk.out");
#define NMAX 500005
int fr[NMAX];
int main()
{
int n,a,b,k; fin >> n>>k>>a>>b;
vector<int> pos(n + 1, -1);
pos[0] = 0;
unsigned long long ps = 0;
int sol = 0;
for (int i = 1; i <= n; i++) {
//cout<<i<<endl;
int x; fin >> x;
ps = (ps + x) % k;
//cout<<ps<<endl;
if (pos[ps] != -1 && (i - pos[ps] + 1 >= a && i - pos[ps] + 1 <= b)) {
sol++;
if(pos[0] == pos[ps]+1)
sol++;
}
pos[ps] = i;
}
fout<<sol;
}