Cod sursa(job #3309)
Utilizator | Data | 23 decembrie 2006 15:47:11 | |
---|---|---|---|
Problema | Divk | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <stdio.h>
long tmp, sol, n, k, a, b, v[1<<19], r[1<<19];
int main()
{
freopen("divk.in","r",stdin);
freopen("divk.out","w",stdout);
register long i;
scanf("%ld %ld %ld %ld\n", &n, &k, &a, &b);
r[0]=k;
for(i=1;i<=n;++i)
{
scanf("%ld\n",&tmp);
r[i]=(r[i-1]+tmp)%k;
}
for(i=a;i<=n;++i)
{
if((i>=a)&&(i-a<n))
++v[r[i-a]];
if((i>=b+1)&&(i-b-1<n))
--v[r[i-b-1]];
sol+=v[r[i]];
}
printf("%ld\n", sol);
return 0;
}
/*
1 2 3 4 5 6 7 8
*/