Cod sursa(job #2497933)

Utilizator qweryclujRadu Alexandru qwerycluj Data 23 noiembrie 2019 12:32:18
Problema Divk Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.56 kb
#include<iostream>
#include<fstream>

using namespace std;

int main()

{
	int k, N, a[1000], cont = 0, s = 0, A, B, c = 0;
	ifstream fin("divk.in");
	ofstream fout("divk.out");
	fin >> N;
	fin >> k;
	fin >> A;
	fin >> B;
	for (int i = 0;i < N;i++)
	{
		fin >> a[i];
		a[i] = a[i] % k;
	}
	for (int i = 0;i < N;i++)
	{
		c = 1;
		s = a[i];
		for (int z = i+1;z < N;z++)
		{
			c++;
			s = s + a[z];
			if (c > B)
				break;
			if (s % k == 0 && c>=A)
			{
				cont++;
			}
		}
	}
	fout << cont;
	fin.close();
	fout.close();
	return 0;
}