Pagini recente » Cod sursa (job #1544652) | Cod sursa (job #2438431) | Borderou de evaluare (job #2688045) | Cod sursa (job #1544682) | Cod sursa (job #930438)
Cod sursa(job #930438)
#include<cstdio>
using namespace std;
int j,nr,n,k,a,b,i,v[500010],sp[500010];
void sumepart()
{
for(i=1;i<=n;i++)
{sp[i]=sp[i-1]+v[i];
sp[i]=sp[i]%k;
}
}
int main()
{
freopen("divk.in","r",stdin);
freopen("divk.out","w",stdout);
scanf("%d%d%d%d",&n,&k,&a,&b);
for(i=1;i<=n;i++) scanf("%d",&v[i]);
sumepart();
for(i=a;i<=b;i++)
{
for(j=1;j<=n-i+1;j++)
{if(sp[j+i-1]-sp[j-1]==0) nr++;
}
}
printf("%d",nr);
return 0;
}