Cod sursa(job #671305)
Utilizator | Data | 31 ianuarie 2012 09:56:36 | |
---|---|---|---|
Problema | Divk | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include<stdio.h>
const int C=9001,N=500001;
int sum[N],f[N];
int main()
{
freopen("divk.in","r",stdin);
freopen("divk.out","w",stdout);
int n,i,x,j,A,B,K,p;
scanf("%d%d%d%d",&n,&K,&A,&B);
long long rez=0;
int a=0,b=0;
for(i=1;i<=n;i++)
{
scanf("%d",&x);
sum[i]=(sum[i-1]+x)%K;
f[sum[i]]++;
if(f[sum[i]]>=A)
if(f[sum[i]]<=B)
rez+=(f[sum[i]]-1);
else rez+=B;
}
printf("%d",rez);
}