Cod sursa(job #1705863)

Utilizator GabiTulbaGabi Tulba-Lecu GabiTulba Data 21 mai 2016 00:47:25
Problema Divk Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <cstdio>

using namespace std;

int N,K,A,B,val=0;
long long v[500005]={};
bool used[500005]={};
void Read()
{
	scanf("%d%d%d%d",&N,&K,&A,&B);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&v[i]);
		v[i]+=v[i-1];
	}
}

int main()
{
	freopen("divk.in","r",stdin);
	freopen("divk.out","w",stdout);

	Read();
	for(int i=A;i<=B;i++)
		for(int j=1;j<=N-i+1;j++)
			if(!used[j]&&(v[j+i-1]-v[j-1])%K==0)
			{
				val++;
				used[j]=true;
			}
	printf("%d",val);
	return 0;
}