Cod sursa(job #2581300)

Utilizator valentinchipuc123Valentin Chipuc valentinchipuc123 Data 14 martie 2020 20:51:09
Problema Divk Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.31 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("divk.in");
ofstream g("divk.out");

long long cnt;
int k,B,A,n,x,p[99999],v[500001];

int main()
{
f>>n>>k>>A>>B;
for(int i=1;i<=n;i++)
{
 f>>x;
 v[i]=(v[i-1]+x)%k;
if(i>=A) p[v[i-A]]++;
if(i>B) p[v[i-B-1]]--;
 cnt+=p[v[i]];
}
g<<cnt;
}