Cod sursa(job #1768229)

Utilizator Lungu007Lungu Ionut Lungu007 Data 30 septembrie 2016 16:03:19
Problema Divk Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <iostream>
#include <fstream>
#define NMAX 500001
using namespace std;

ifstream in("divk.in");
ofstream out("divk.out");

int a[NMAX],n,x,y,k,contor;

int main()
{
    in >> n >> k >> x >> y;

    for(int i=1;i<=n;i++)
    {
        in >> a[i];
    }

     for(int i=1;i<=n;i++)
    {
        a[i]= (a[i] +a[i-1])%k;
    }

     for(int i=1;i<=n;i++)
    {
        for(int j=i+x-1;j<=i+y-1 && j<=n;j++)
        {
            if((a[j]-a[i-1]+k)%k==0)
            {
                contor++;
               //s cout << i << " " << j << endl;
            }
        }
    }

    out << contor;

    return 0;
}