Cod sursa(job #667449)
Utilizator | Popescu Anca anca1243 | Data | 23 ianuarie 2012 09:53:35 |
---|---|---|---|
Problema | Divk | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
using namespace std;
long long sum[500001];
int fv[100002];
int main()
{
ifstream f("divk.in");
ofstream g("divk.out");
int N,K,A,B,x,i,nrs=0;
f>>N>>K>>A>>B;
for(i=1;i<=N;i++)
{
f>>x;
sum[i]=(sum[i-1]+x)%K;
if(i>B)
fv[sum[i-B]]--;
if(i>A)
fv[sum[i-A]]++;
fv[sum[i]]++;
nrs+=fv[sum[i]]-1;
if(sum[i]==0) nrs++;
}
g<<nrs<<"\n";
}