Cod sursa(job #84418)
Utilizator | Data | 14 septembrie 2007 22:55:57 | |
---|---|---|---|
Problema | Divk | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include<stdio.h>
long a, b, n, k, v[500000], contor, s[500000];
void citire()
{
long i;
freopen("divk.in","r",stdin);
freopen("divk.out","w",stdout);
scanf("%ld %ld %ld %ld",&n, &k, &a, &b);
for (i=1; i<=n; i++){ scanf ("%ld",&v[i]); s[i]=(s[i-1]+v[i])%k;}
}
void calcul()
{
long i, j;
for (i=1; i<=n-a+1; i++)
for (j=i+a-1; j<=n && j<=i+b-1; j++)
if (s[i]%k==s[j]%k) contor++;
printf("%ld",contor);
}
int main()
{
citire();
calcul();
return 0;
}