Cod sursa(job #1704299)

Utilizator VladTiberiuMihailescu Vlad Tiberiu VladTiberiu Data 18 mai 2016 16:12:27
Problema Divk Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <bits/stdc++.h>

#define NMax 500005
#define ll long long
using namespace std;
ifstream f("divk.in");
ofstream g("divk.out");

ll n,k,x,y,ANS;
ll a[NMax],sum[NMax];

int main()
{
    f >> n >> k >> x >> y;
    for(int i = 1; i <= n; ++i){
        f >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    for(int i = 1; i <= n; ++i){
        for(int j = x; j <= y; ++j)
            if(i - j >= 0)
                if(!((sum[i] - sum[i - j]) % k))
                    ++ANS;
    }
    g << ANS << '\n';
    return 0;
}