Cod sursa(job #2177282)

Utilizator ivddabDabelea Ioana-Viviana ivddab Data 18 martie 2018 13:52:38
Problema Divk Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <fstream>
#define NM 100002
using namespace std;
ifstream f("divk.in");
ofstream g("divk.out");
int n,k,A,B,i,j,nr,a,rz;
int x[NM*5],rest[NM];
int main()
{
    f>>n>>k>>A>>B;
    for(i=1;i<=n;i++){
        f>>x[i];
        x[i]=(x[i]+x[i-1])%k;
        if(i>=A)  rest[x[i-A]]++;
        if(i-B>=1)rest[x[i-B-1]]--;
        rz+=rest[x[i]];
    }
    g<<rz<<'\n';
    return 0;
}