Cod sursa(job #1417948)

Utilizator LegionHagiu Stefan Legion Data 11 aprilie 2015 15:09:39
Problema Divk Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <iostream>
#include <fstream>
using namespace std;
long long sume[500001];
int main()
{
	ifstream in("divk.in");
	ofstream out("divk.out");
	int n, a, b, i, x,j, k, total = 0;
	in >> n;
	in >> k;
	in >> a;
	in >> b;
	for (i = 1; i <= n; i++)
	{
		in >> x;
		sume[i] = x + sume[i - 1];
	}
	for (i = a; i <= n; i++)
	{
		for (j = i - a; j >= i - b&&j >= 0; j--)
		{
			if ((sume[i] - sume[j]) % k == 0)
			{
				total++;
			}
		}
	}
	out << total;
}